// Type definitions for camo v0.11.4 // Project: https://github.com/scottwrobinson/camo // Definitions by: Lucas Matías Ciruzzi // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare module "camo" { type TypeOrArray = Type | Type[]; /** * Supported type constructors for document properties */ export type SchemaTypeConstructor = TypeOrArray | TypeOrArray | TypeOrArray | TypeOrArray | TypeOrArray | TypeOrArray; /** * Supported types for document properties */ export type SchemaType = TypeOrArray; /** * Document property with options */ export interface SchemaTypeOptions { /** * Type of data */ type: SchemaTypeConstructor; /** * Default value */ default?: Type; /** * Min value (only with Number) */ min?: number; /** * Max value (only with Number) */ max?: number; /** * Posible options */ choices?: Type[]; /** * RegEx to match value */ match?: RegExp; /** * Validation function * * @param value Value taken * @returns true (validation ok) or false (validation wrong) */ validate?(value: Type): boolean; /** * Unique value (like ids) */ unique?: boolean; /** * Required field */ required?: boolean; } /** * Document property type or options */ export type SchemaTypeExtended = SchemaTypeConstructor | SchemaTypeOptions; /** * Schema passed to Document.create() */ interface DocumentSchema { /** * Index signature */ [property: string]: SchemaType; /** * Document id */ _id?: string; } /** * Camo document instance */ class DocumentInstance { public save(): Promise; public loadOne(): Promise; public loadMany(): Promise; public delete(): Promise; public deleteOne(): Promise; public deleteMany(): Promise; public loadOneAndDelete(): Promise; public count(): Promise; public preValidate(): Promise; public postValidate(): Promise; public preSave(): Promise; public postSave(): Promise; public preDelete(): Promise; public postDelete(): Promise; } /** * Camo document */ export class Document { /** * Index signature */ [property: string]: SchemaTypeExtended | string | DocumentInstance; /** * Static method to define the collection name * * @returns The collection name */ static collectionName(): string; /** * Creates a camo document instance * * @returns A camo document instance */ static create(schema: Schema): DocumentInstance; } /** * Connect function * * @param uri Connection URI */ export function connect (uri: string): Promise; }