@bedrockio/model 0.5.0 → 0.5.1

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.
@@ -441,7 +441,7 @@ function getRefField(schema, path) {
441
441
  for (let i = 1; i < split.length; i++) {
442
442
  const base = split.slice(0, i);
443
443
  const rest = split.slice(i);
444
- const type = schema.path(base);
444
+ const type = schema.path(base.join('.'));
445
445
  if (type instanceof SchemaTypes.ObjectId) {
446
446
  return {
447
447
  type,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bedrockio/model",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "description": "Bedrock utilities for model creation.",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -31,7 +31,7 @@
31
31
  },
32
32
  "peerDependencies": {
33
33
  "@bedrockio/yada": "^1.1.2",
34
- "mongoose": "^7.6.13"
34
+ "mongoose": "^8.5.1"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@babel/cli": "^7.20.7",
@@ -45,7 +45,7 @@
45
45
  "jest": "^29.4.1",
46
46
  "jest-environment-node": "^29.4.1",
47
47
  "mongodb": "^6.5.0",
48
- "mongoose": "7.6.13",
48
+ "mongoose": "^8.5.1",
49
49
  "prettier-eslint": "^15.0.1",
50
50
  "typescript": "^4.9.5"
51
51
  },
package/src/search.js CHANGED
@@ -473,7 +473,7 @@ function getRefField(schema, path) {
473
473
  for (let i = 1; i < split.length; i++) {
474
474
  const base = split.slice(0, i);
475
475
  const rest = split.slice(i);
476
- const type = schema.path(base);
476
+ const type = schema.path(base.join('.'));
477
477
  if (type instanceof SchemaTypes.ObjectId) {
478
478
  return {
479
479
  type,
package/types/load.d.ts CHANGED
@@ -4,73 +4,7 @@
4
4
  * @param {string} name
5
5
  * @returns mongoose.Model
6
6
  */
7
- export function loadModel(definition: object, name: string): mongoose.Model<any, any, any, any, any, mongoose.Schema<any, mongoose.Model<any, any, any, any, any, any>, any, any, any, {
8
- [x: string]: any;
9
- }, {
10
- autoIndex?: boolean;
11
- autoCreate?: boolean;
12
- bufferCommands?: boolean;
13
- bufferTimeoutMS?: number;
14
- capped?: number | boolean | {
15
- size?: number;
16
- max?: number;
17
- autoIndexId?: boolean;
18
- };
19
- collation?: mongoose.mongo.CollationOptions;
20
- collectionOptions?: mongoose.mongo.CreateCollectionOptions;
21
- timeseries?: mongoose.mongo.TimeSeriesCollectionOptions;
22
- expireAfterSeconds?: number;
23
- expires?: string | number;
24
- collection?: string;
25
- discriminatorKey?: string;
26
- excludeIndexes?: boolean;
27
- id?: boolean;
28
- _id?: boolean;
29
- minimize?: boolean;
30
- optimisticConcurrency?: boolean;
31
- pluginTags?: string[];
32
- read?: string;
33
- writeConcern?: mongoose.mongo.WriteConcern;
34
- safe?: boolean | {
35
- w?: string | number;
36
- wtimeout?: number;
37
- j?: boolean;
38
- };
39
- shardKey?: Record<string, unknown>;
40
- strict?: boolean | "throw";
41
- strictQuery?: boolean | "throw";
42
- toJSON: {
43
- getters: boolean;
44
- versionKey: boolean;
45
- transform: (doc: any, ret: any, options: any) => void;
46
- } | mongoose.ToObjectOptions<any>;
47
- toObject: {
48
- getters: boolean;
49
- versionKey: boolean;
50
- transform: (doc: any, ret: any, options: any) => void;
51
- } | mongoose.ToObjectOptions<any>;
52
- typeKey?: string;
53
- validateBeforeSave?: boolean;
54
- validateModifiedOnly?: boolean;
55
- versionKey?: string | boolean;
56
- selectPopulatedPaths?: boolean;
57
- skipVersioning?: {
58
- [key: string]: boolean;
59
- };
60
- storeSubdocValidationError?: boolean;
61
- timestamps: boolean | mongoose.SchemaTimestampsConfig;
62
- suppressReservedKeysWarning?: boolean;
63
- statics?: {
64
- [x: string]: any;
65
- };
66
- methods?: any;
67
- query?: any;
68
- castNonArrays?: boolean;
69
- virtuals?: mongoose.SchemaOptionsVirtualsPropertyType<any, any, any>;
70
- overwriteModels?: boolean;
71
- }, any, any>> & {
72
- [x: string]: any;
73
- };
7
+ export function loadModel(definition: object, name: string): any;
74
8
  /**
75
9
  * Loads all model definitions in the given directory.
76
10
  * Returns the full loaded model set.
@@ -1 +1 @@
1
- {"version":3,"file":"load.d.ts","sourceRoot":"","sources":["../src/load.js"],"names":[],"mappings":"AAQA;;;;;GAKG;AACH,sCAJW,MAAM,QACN,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAahB;AAED;;;;GAIG;AACH,sCAFW,MAAM,mBAkBhB"}
1
+ {"version":3,"file":"load.d.ts","sourceRoot":"","sources":["../src/load.js"],"names":[],"mappings":"AAQA;;;;;GAKG;AACH,sCAJW,MAAM,QACN,MAAM,OAahB;AAED;;;;GAIG;AACH,sCAFW,MAAM,mBAkBhB"}
package/types/schema.d.ts CHANGED
@@ -6,10 +6,9 @@
6
6
  * @param {mongoose.SchemaOptions} options
7
7
  * @returns mongoose.Schema
8
8
  */
9
- export function createSchema(definition: object, options?: mongoose.SchemaOptions): mongoose.Schema<any, mongoose.Model<any, any, any, any, any, any>, any, any, any, {
10
- [x: string]: any;
11
- }, {
9
+ export function createSchema(definition: object, options?: mongoose.SchemaOptions): mongoose.Schema<any, mongoose.Model<any, any, any, any, any, any>, any, any, any, any, {
12
10
  autoIndex?: boolean;
11
+ autoSearchIndex?: boolean;
13
12
  autoCreate?: boolean;
14
13
  bufferCommands?: boolean;
15
14
  bufferTimeoutMS?: number;
@@ -32,6 +31,9 @@ export function createSchema(definition: object, options?: mongoose.SchemaOption
32
31
  optimisticConcurrency?: boolean;
33
32
  pluginTags?: string[];
34
33
  read?: string;
34
+ readConcern?: {
35
+ level: "local" | "available" | "majority" | "snapshot" | "linearizable";
36
+ };
35
37
  writeConcern?: mongoose.mongo.WriteConcern;
36
38
  safe?: boolean | {
37
39
  w?: string | number;
@@ -62,10 +64,8 @@ export function createSchema(definition: object, options?: mongoose.SchemaOption
62
64
  storeSubdocValidationError?: boolean;
63
65
  timestamps: boolean | mongoose.SchemaTimestampsConfig;
64
66
  suppressReservedKeysWarning?: boolean;
65
- statics?: {
66
- [x: string]: any;
67
- };
68
- methods?: any;
67
+ statics?: mongoose.AddThisParameter<any, mongoose.Model<any, {}, {}, {}, any, any>>;
68
+ methods?: mongoose.AddThisParameter<any, any> & mongoose.AnyObject;
69
69
  query?: any;
70
70
  castNonArrays?: boolean;
71
71
  virtuals?: mongoose.SchemaOptionsVirtualsPropertyType<any, any, any>;