@mathrunet/masamune
Version:
Manages packages for the server portion (NodeJS) of the Masamune framework.
248 lines (247 loc) • 8.29 kB
TypeScript
import * as firestore from "firebase-admin/firestore";
import { ModelGeoValue, ModelRefBase, ModelTimestamp, ModelVectorValue } from "../model_field_value/model_field_value";
/**
* Document model.
*
* ドキュメントモデル。
*
* @param {firestore.DocumentSnapshot<AppModelType, DbModelType>} source
* Source document snapshot.
*
* ソースドキュメントスナップショット。
*
* @param {AppModelType | undefined} data
* Data.
*
* データ。
*
* @returns {DocumentModel<AppModelType, DbModelType>}
* Document model.
*
* ドキュメントモデル。
*/
export declare class DocumentModel<AppModelType, DbModelType extends firestore.DocumentData> implements firestore.DocumentSnapshot<AppModelType, DbModelType> {
constructor(source: firestore.DocumentSnapshot<AppModelType, DbModelType>, data: AppModelType | undefined);
data(): AppModelType | undefined;
get(fieldPath: string | firestore.FieldPath): any;
isEqual(other: firestore.DocumentSnapshot<AppModelType, DbModelType>): boolean;
protected _data: AppModelType | undefined;
protected _source: firestore.DocumentSnapshot<AppModelType, DbModelType>;
readonly exists: boolean;
readonly ref: firestore.DocumentReference<AppModelType, DbModelType>;
readonly id: string;
readonly createTime?: firestore.Timestamp;
readonly updateTime?: firestore.Timestamp;
readonly readTime: firestore.Timestamp;
}
/**
* Query document model.
*
* クエリドキュメントモデル。
*
* @param {firestore.QueryDocumentSnapshot<AppModelType, DbModelType>} source
* Source query document snapshot.
*
* ソースクエリドキュメントスナップショット。
*
* @param {AppModelType | undefined} data
* Data.
*
* データ。
*
* @returns {QueryDocumentModel<AppModelType, DbModelType>}
* Query document model.
*
* クエリドキュメントモデル。
*/
export declare class QueryDocumentModel<AppModelType, DbModelType extends firestore.DocumentData> extends DocumentModel<AppModelType, DbModelType> implements firestore.QueryDocumentSnapshot<AppModelType, DbModelType> {
constructor(source: firestore.QueryDocumentSnapshot<AppModelType, DbModelType>, data: AppModelType | undefined);
data(): AppModelType;
get(fieldPath: string | firestore.FieldPath): any;
isEqual(other: firestore.QueryDocumentSnapshot<AppModelType, DbModelType>): boolean;
readonly createTime: firestore.Timestamp;
readonly updateTime: firestore.Timestamp;
}
/**
* Document change model.
*
* ドキュメント変更モデル。
*
* @param {firestore.DocumentChange<AppModelType, DbModelType>} source
* Source document change.
*
* ソースドキュメント変更。
*
* @param {QueryDocumentModel<AppModelType, DbModelType>} doc
* Document model.
*
* ドキュメントモデル。
*
* @returns {DocumentChangeModel<AppModelType, DbModelType>}
* Document change model.
*
* ドキュメント変更モデル。
*/
export declare class DocumentChangeModel<AppModelType, DbModelType extends firestore.DocumentData> implements firestore.DocumentChange<AppModelType, DbModelType> {
constructor(source: firestore.DocumentChange<AppModelType, DbModelType>, doc: QueryDocumentModel<AppModelType, DbModelType>);
isEqual(other: firestore.DocumentChange<AppModelType, DbModelType>): boolean;
private _source;
readonly type: firestore.DocumentChangeType;
readonly doc: QueryDocumentModel<AppModelType, DbModelType>;
readonly oldIndex: number;
readonly newIndex: number;
}
/**
* Collection model.
*
* コレクションモデル。
*
* @param {firestore.QuerySnapshot<AppModelType, DbModelType>} source
* Source query snapshot.
*
* ソースクエリスナップショット。
*
* @param {Array<QueryDocumentModel<AppModelType, DbModelType>>} data
* Data.
*
* データ。
*
* @param {DocumentChangeModel<AppModelType, DbModelType>[]} changes
* Changes.
*
* 変更内容。
*
* @returns {CollectionModel<AppModelType, DbModelType>}
* Collection model.
*
* コレクションモデル。
*/
export declare class CollectionModel<AppModelType, DbModelType extends firestore.DocumentData> implements firestore.QuerySnapshot<AppModelType, DbModelType> {
constructor(source: firestore.QuerySnapshot<AppModelType, DbModelType>, data: Array<QueryDocumentModel<AppModelType, DbModelType>>, changes: DocumentChangeModel<AppModelType, DbModelType>[]);
private _changes;
private _source;
docChanges(): DocumentChangeModel<AppModelType, DbModelType>[];
forEach(callback: (result: QueryDocumentModel<AppModelType, DbModelType>) => void, thisArg?: any): void;
isEqual(other: firestore.QuerySnapshot<AppModelType, DbModelType>): boolean;
readonly query: firestore.Query<AppModelType, DbModelType>;
readonly docs: Array<QueryDocumentModel<AppModelType, DbModelType>>;
readonly size: number;
readonly empty: boolean;
readonly readTime: firestore.Timestamp;
}
declare module "firebase-admin/firestore" {
interface DocumentReference<AppModelType, DbModelType extends firestore.DocumentData> {
/**
* Load the document.
*
* ドキュメントを読み込みます。
*
* @returns {Promise<DocumentModel<AppModelType, DbModelType>>}
* Document model.
*
* ドキュメントモデル。
*/
load(): Promise<DocumentModel<AppModelType, DbModelType>>;
/**
* Save the document.
*
* ドキュメントを保存します。
*
* @param {firestore.PartialWithFieldValue<AppModelType>} data
* Data to save.
*
* 保存するデータ。
*
* @param {firestore.SetOptions} options
* Options for saving.
*
* 保存オプション。
*
* @returns {Promise<firestore.WriteResult>}
* Write result.
*
* 書き込み結果。
*/
save(data: firestore.PartialWithFieldValue<AppModelType>, options: firestore.SetOptions): Promise<firestore.WriteResult>;
/**
* Save the document.
*
* ドキュメントを保存します。
*
* @param data Data to save.
*
* 保存するデータ。
*
* @returns {Promise<firestore.WriteResult>}
* Write result.
*
* 書き込み結果。
*/
save(data: firestore.WithFieldValue<AppModelType>): Promise<firestore.WriteResult>;
/**
* Convert to ModelRefBase.
*
* ModelRefBaseに変換します。
*
* @returns {ModelRefBase}
* ModelRefBase.
*
* ModelRefBase。
*/
toModelRefBase(): ModelRefBase;
}
interface Query<AppModelType, DbModelType extends firestore.DocumentData> {
/**
* Load the collection.
*
* コレクションを読み込みます。
*
* @returns {Promise<CollectionModel<AppModelType, DbModelType>>}
* Collection model.
*
* コレクションモデル。
*/
load(): Promise<CollectionModel<AppModelType, DbModelType>>;
}
interface Timestamp {
/**
* Convert to ModelTimestamp.
*
* ModelTimestampに変換します。
*
* @returns {ModelTimestamp}
* ModelTimestamp.
*
* ModelTimestamp。
*/
toModelTimestamp(): ModelTimestamp;
}
interface GeoPoint {
/**
* Convert to ModelGeoValue.
*
* ModelGeoValueに変換します。
*
* @returns {ModelGeoValue}
* ModelGeoValue.
*
* ModelGeoValue。
*/
toModelGeoValue(): ModelGeoValue;
}
}
declare module "@google-cloud/firestore" {
interface VectorValue {
/**
* Convert to ModelVectorValue.
*
* ModelVectorValueに変換します。
*
* @returns {ModelVectorValue}
* ModelVectorValue.
*
* ModelVectorValue。
*/
toModelVectorValue(): ModelVectorValue;
}
}