import { Document, FilterQuery, Schema, SchemaType, SchemaTypeOptions } from "mongoose"; import { APIErrorConstructor } from "./errors"; export interface BaseUser { admin: boolean; email: string; } export declare function baseUserPlugin(schema: Schema): void; /** For models with the isDeletedPlugin, extend this interface to add the appropriate fields. */ export interface IsDeleted { deleted: boolean; } export declare function isDeletedPlugin(schema: Schema, defaultValue?: boolean): void; export declare function isDisabledPlugin(schema: Schema, defaultValue?: boolean): void; export interface CreatedDeleted { updated: { type: Date; required: true; }; created: { type: Date; required: true; }; } export declare function createdUpdatedPlugin(schema: Schema): void; export declare function firebaseJWTPlugin(schema: Schema): void; /** * This adds a static method `Model.findOneOrNone` to the schema. This should replace `Model.findOne` in most instances. * `Model.findOne` should only be used with a unique index, but that's not apparent from the docs. Otherwise you can wind * up with a random document that matches the query. The returns either null if no document matches, the actual * document, or throws an exception if multiple are found. * @param schema Mongoose Schema */ export declare function findOneOrNone(schema: Schema): void; /** * This adds a static method `Model.findExactlyOne` to the schema. This or findOneOrNone should replace `Model.findOne` * in most instances. * `Model.findOne` should only be used with a unique index, but that's not apparent from the docs. Otherwise you can wind * up with a random document that matches the query. The returns the one matching document, or throws an exception if * multiple or none are found. * @param schema Mongoose Schema */ export declare function findExactlyOne(schema: Schema): void; /** * This adds a static method `Model.upsert` to the schema. This method will either update an existing document * that matches the conditions or create a new document if none exists. It throws an error if multiple documents * match the conditions to prevent ambiguous updates. * @param schema Mongoose Schema */ export declare function upsertPlugin(schema: Schema): void; /** For models with the upsertPlugin, extend this interface to add the upsert static method. */ export interface HasUpsert { upsert(conditions: Record, update: Record): Promise; } export interface FindOneOrNonePlugin { findOneOrNone(query: FilterQuery, errorArgs?: Partial): Promise<(Document & T) | null>; } export interface FindExactlyOnePlugin { findExactlyOne(query: FilterQuery, errorArgs?: Partial): Promise; } export declare class DateOnly extends SchemaType { constructor(key: string, options: SchemaTypeOptions); handleSingle(val: any): Date | undefined; $conditionalHandlers: any; castForQuery($conditional: any, val: any, context: any): Date | undefined; cast(val: any): Date | undefined; get(val: any): this; }