1 | /// <reference types="node" />
|
2 | import * as mongoose from 'mongoose';
|
3 | import type { DocumentType, Ref, RefType } from './types';
|
4 | /**
|
5 | * Check if the given document is populated
|
6 | * @param doc The Ref with uncertain type
|
7 | */
|
8 | export declare function isDocument<T, S extends RefType>(doc: Ref<T, S> | null | undefined): doc is DocumentType<T>;
|
9 | /**
|
10 | * Check if the given array is fully populated
|
11 | * Only returns "true" if all members in the array are populated
|
12 | * @param docs The Array of Refs with uncertain type
|
13 | */
|
14 | export declare function isDocumentArray<T, S extends RefType>(docs: mongoose.Types.Array<Ref<T, S>> | null | undefined): docs is mongoose.Types.Array<DocumentType<NonNullable<T>>>;
|
15 | /**
|
16 | * Check if the given array is fully populated
|
17 | * Only returns "true" if all members in the array are populated
|
18 | * @param docs The Array of Refs with uncertain type
|
19 | */
|
20 | export declare function isDocumentArray<T, S extends RefType>(docs: Ref<T, S>[] | null | undefined): docs is DocumentType<NonNullable<T>>[];
|
21 | type AllowedRefTypes = typeof String | typeof Number | typeof Buffer | typeof mongoose.Types.ObjectId | typeof mongoose.Types.Buffer;
|
22 | /**
|
23 | * Check if the document is of type "refType"
|
24 | * @param doc The Ref with uncretain type
|
25 | * @param refType The Expected Reference Type (this is required because this type is only known at compile time, not at runtime)
|
26 | */
|
27 | export declare function isRefType<T, S extends RefType>(doc: Ref<T, S> | null | undefined, refType: AllowedRefTypes): doc is NonNullable<S>;
|
28 | /**
|
29 | * Check if the array is fully of type "refType"
|
30 | * Only returns "true" if all members in the array are of type "refType"
|
31 | * @param docs The Ref with uncretain type
|
32 | * @param refType The Expected Reference Type (this is required because this type is only known at compile time, not at runtime)
|
33 | */
|
34 | export declare function isRefTypeArray<T, S extends RefType>(docs: mongoose.Types.Array<Ref<T, S>> | null | undefined, refType: AllowedRefTypes): docs is mongoose.Types.Array<NonNullable<S>>;
|
35 | /**
|
36 | * Check if the array is fully of type "refType"
|
37 | * Only returns "true" if all members in the array are of type "refType"
|
38 | * @param docs The Ref with uncretain type
|
39 | * @param refType The Expected Reference Type (this is required because this type is only known at compile time, not at runtime)
|
40 | */
|
41 | export declare function isRefTypeArray<T, S extends RefType>(docs: Ref<T, S>[] | null | undefined, refType: AllowedRefTypes): docs is NonNullable<S>[];
|
42 | /**
|
43 | * Check if the input is a mongoose.Model
|
44 | * @param model The Value to check
|
45 | */
|
46 | export declare function isModel(model: any): model is mongoose.Model<any>;
|
47 | export {};
|