@brimble/models 4.0.4 → 4.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/types/ref.d.ts +7 -5
- package/package.json +1 -1
package/dist/types/ref.d.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { Types } from "mongoose";
|
|
2
2
|
/**
|
|
3
|
-
* A Mongoose reference field.
|
|
4
|
-
*
|
|
5
|
-
* (or a named alias
|
|
3
|
+
* A Mongoose reference field. Accepts a string id or ObjectId when writing;
|
|
4
|
+
* holds an ObjectId in storage unless the query populated it. Type populated
|
|
5
|
+
* query results as `Populated<T, K>` (or a named alias) so callers know which
|
|
6
|
+
* refs are documents.
|
|
6
7
|
*/
|
|
7
|
-
export type Ref<T> = T | Types.ObjectId;
|
|
8
|
-
type
|
|
8
|
+
export type Ref<T> = T | Types.ObjectId | string;
|
|
9
|
+
type UnpopulatedRef = Types.ObjectId | string;
|
|
10
|
+
type PopulatedField<V> = V extends (infer E)[] ? Exclude<E, UnpopulatedRef>[] : Exclude<V, UnpopulatedRef>;
|
|
9
11
|
/**
|
|
10
12
|
* Narrows the named reference fields of `T` to their populated documents. Use it
|
|
11
13
|
* on query return types so the populate contract lives with the query that
|