import type { BaseDocument, DocumentModelInstance, GenericObject, IDocumentModelClass } from '../web/database/firestore/types'; import type { ISetDocument, IGetDocument, IDeleteDocument, IDocumentModelConstructor } from './types'; declare class DocumentModel implements IDocumentModelClass { [key: string]: any; private collection; private id?; private _data; private defaults?; private schema; private changedFields; private getDocument; private setDocument; private deleteDocument; constructor({ collection, schema: structure, defaults, data, getDocument, setDocument, deleteDocument }: IDocumentModelConstructor); private isExistentField; private generateAccessors; private getValue; private setValue; getCollection(): string; getId(): string; setId(value: string): void; set(data: GenericObject): void; getChanges(): GenericObject; resetChanges(): void; hasChanged(): boolean; hasFieldsChanged(...fields: string[]): boolean; commit(): Promise; get(): Promise; delete(): Promise; toJSON(): GenericObject; toString(): string; } /** * @example * // Declare the JavaScript object to be used as the schema * const config = { * age: 25, * name: "John Doe", * isActive: true, * address: { * city: "New York", * zip: 10001, * }, * }; * * // Usage with type suggestions * const User = createModel({ * name: 'users', * schema: config, * defaults: { ...config }, * getDocument: async (collection, id) => { ... }, * setDocument: async (collection, id, data) => { ... }, * deleteDocument: async (collection, id) => { ... }, * data: { ...config }, * }); * * // All these will have proper type suggestions * User.name = 'Jane Doe'; // string * User.age = 31; // number * console.log(User.address); // object * console.log(User.isActive); // true * console.log(User.address?.city); // 'New York' * @param collection - Firestore collection name eg. 'users' or 'posts/postId/comments' * @param schema - JS object to be used to create the model schema * @param defaults - Optional default values to be used to populate the model * @param data - Optional data to be used to populate the model * @returns - A new instance of the DocumentModel class */ declare function createModel({ collection, schema, defaults, data, getDocument, setDocument, deleteDocument }: IDocumentModelConstructor): DocumentModelInstance; declare function prepareModel(collection: string, schema: GenericObject, getDocument: IGetDocument, setDocument: ISetDocument, deleteDocument: IDeleteDocument, defaults?: () => GenericObject): () => DocumentModelInstance; export { DocumentModel, prepareModel, createModel, }; //# sourceMappingURL=Model.d.ts.map