monguito
Version:
MongoDB Abstract Repository implementation for Node.js
46 lines (45 loc) • 1.95 kB
TypeScript
import { SchemaOptions as MongooseSchemaOptions, Schema, SchemaDefinition } from 'mongoose';
export type SchemaPlugin = {
fn: (schema: Schema) => void;
options?: any;
};
export type SchemaOptions = MongooseSchemaOptions & {
plugins?: SchemaPlugin[];
};
/**
* Base schema to be extended by all persistable domain object schemas.
*/
export declare const BaseSchema: Schema<any, import("mongoose").Model<any, any, any, any, any, any>, {}, {}, {}, {}, {
toObject: {
transform: (document: any, result: any) => void;
};
}, {}, any>;
/**
* Schema to be extended by all persistable domain objects that require audit capability.
*/
export declare const AuditableSchema: Schema<any, import("mongoose").Model<any, any, any, any, any, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, {
[x: string]: unknown;
}, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<{
[x: string]: unknown;
}>> & import("mongoose").FlatRecord<{
[x: string]: unknown;
}> & Required<{
_id: unknown;
}> & {
__v: number;
}>;
/**
* Creates a new schema from the given data.
* @param {Schema<T>} baseSchema the base schema.
* @param {Schema<S>} extension the schema to extend from.
* @returns {Schema<T & S>} a new schema that integrates the contents of the given parameters.
*/
export declare function extendSchema<T = object, S = object>(baseSchema: Schema<T>, extension: Schema<S>): Schema<T & S>;
/**
* Creates a new schema from the given data.
* @param {Schema<T>} baseSchema the base schema.
* @param {SchemaDefinition<S>} extension the schema definition to extend from.
* @param {SchemaOptions} options (optional) some schema options.
* @returns {Schema<T & S>} a new schema that integrates the contents of the given parameters.
*/
export declare function extendSchema<T = object, S = object>(baseSchema: Schema<T>, extension: SchemaDefinition<S>, options?: SchemaOptions): Schema<T & S>;