/** * @license * Copyright Elegante All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://elegante.dev/license */ import { AggregateOptions, DocumentFilter, Filter, FindOptions, Record, Sort } from './types'; export declare type ActiveModel = Partial | string; export interface ActiveParams { /** * define a default filter for the query (same as MongoDB's) */ filter?: DocumentFilter; /** * define a default sort for the query. (Same as MongoDB's) */ sort?: Sort; /** * define a default projection for the query. (Same as MongoDB's) */ projection?: { [key in keyof T]: number; }; /** * define default options for the Find ang Aggregate operations */ options?: FindOptions | AggregateOptions | undefined; /** * define a default MongoDB aggregation pipeline */ pipeline?: { [key in keyof T]: Filter; }[]; /** * similiar to MySQL's join * This will allow you to join other collections * just by passing a list of pointer names * it accepts nested pointers ie: ['user.profile.photo'] */ include?: string[]; /** * define props to be excluded from the query results * it accepts nested pointers ie: ['user.profile.createdAt'] */ exclude?: string[]; /** * this is a shortcut to multiple "wheres" at same time * * @example * new UserModel({ * name: 'John', * email: 'john@doe.com' * }, { * by: ['name', 'email'] * }) * .fetch() * * will generate the following query: * * { * // ... * filter: { * name: 'John', * email: 'john@doe.com' * } * } */ by?: string[]; /** * pass any data context to the server triggers */ context?: any; /** * whether or not to exclude expired documents by default */ excludeExpiredDocs?: boolean; /** * inspect queries in the server */ inspect?: boolean; /** * operations */ insert?: { updatedAt?: boolean; }; } export declare class ActiveRecord { private params; private collection; private doc; private query; private hit; private objectId; constructor(collection: string, record?: ActiveModel, params?: ActiveParams); get(key: K): Doc[K]; set(key: keyof Doc, value: Doc[K]): void; unset(key: string): void; exists(): boolean; getRawValue(): Doc; fetch(): Promise; save(): Promise; delete(): Promise; pointer(): T; private beforeDocumentSave; private onDocumentRead; private parseDocBeforeSave; }