@brimble/models 1.4.14 → 1.4.16

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/index.js CHANGED
@@ -46,7 +46,12 @@ const mongoose_1 = __importDefault(require("mongoose"));
46
46
  const utils_1 = require("@brimble/utils");
47
47
  // Connection to Mongo
48
48
  const connectToMongo = (mongoUrl) => __awaiter(void 0, void 0, void 0, function* () {
49
- const options = { useNewUrlParser: true, useUnifiedTopology: true };
49
+ const options = {
50
+ useNewUrlParser: true,
51
+ useUnifiedTopology: true,
52
+ poolSize: 10,
53
+ socketTimeoutMS: 30000,
54
+ };
50
55
  mongoose_1.default.set("useFindAndModify", false);
51
56
  mongoose_1.default.set("useCreateIndex", true);
52
57
  // connect to mongo
package/dist/logs.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  /// <reference types="mongoose" />
2
2
  import { ILog } from "./types";
3
- declare const _default: import("mongoose").Model<ILog, {}, {}>;
4
- export default _default;
3
+ declare const Log: import("mongoose").Model<ILog, {}, {}>;
4
+ export default Log;
package/dist/logs.js CHANGED
@@ -22,4 +22,6 @@ const LogSchema = new mongoose_1.Schema({
22
22
  startTime: mongoose_1.Schema.Types.Date,
23
23
  endTime: mongoose_1.Schema.Types.Date,
24
24
  }, { timestamps: true });
25
- exports.default = (0, mongoose_1.model)("Log", LogSchema);
25
+ const Log = (0, mongoose_1.model)("Log", LogSchema);
26
+ Log.ensureIndexes({ _id: 1, project: 1 });
27
+ exports.default = Log;
package/dist/project.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  /// <reference types="mongoose" />
2
2
  import { IProject } from "./types";
3
- declare const _default: import("mongoose").Model<IProject, {}, {}>;
4
- export default _default;
3
+ declare const Project: import("mongoose").Model<IProject, {}, {}>;
4
+ export default Project;
package/dist/project.js CHANGED
@@ -69,4 +69,6 @@ const projectSchema = new mongoose_1.Schema({
69
69
  },
70
70
  screenshot: String,
71
71
  }, { timestamps: true });
72
- exports.default = (0, mongoose_1.model)("Project", projectSchema);
72
+ const Project = (0, mongoose_1.model)("Project", projectSchema);
73
+ Project.ensureIndexes({ _id: 1, updatedAt: 1, createdAt: 1 });
74
+ exports.default = Project;
package/dist/user.d.ts CHANGED
@@ -1,4 +1,3 @@
1
1
  /// <reference types="mongoose" />
2
- import { IUser } from "./types";
3
- declare const _default: import("mongoose").Model<IUser, {}, {}>;
4
- export default _default;
2
+ declare const User: import("mongoose").Model<import("mongoose").Document<any, any, any>, any, any>;
3
+ export default User;
package/dist/user.js CHANGED
@@ -54,4 +54,7 @@ const userSchema = new mongoose_1.Schema({
54
54
  type: String,
55
55
  },
56
56
  }, { timestamps: true });
57
- exports.default = (0, mongoose_1.model)("User", userSchema);
57
+ const User = (0, mongoose_1.model)("User", userSchema);
58
+ // Create indexes for _id and email
59
+ User.ensureIndexes({ _id: 1, email: 1 });
60
+ exports.default = User;
package/index.ts CHANGED
@@ -37,7 +37,12 @@ import { log } from "@brimble/utils";
37
37
 
38
38
  // Connection to Mongo
39
39
  export const connectToMongo = async (mongoUrl: string): Promise<void> => {
40
- const options = { useNewUrlParser: true, useUnifiedTopology: true };
40
+ const options = {
41
+ useNewUrlParser: true,
42
+ useUnifiedTopology: true,
43
+ poolSize: 10,
44
+ socketTimeoutMS: 30000,
45
+ };
41
46
  mongoose.set("useFindAndModify", false);
42
47
  mongoose.set("useCreateIndex", true);
43
48
 
@@ -61,4 +66,3 @@ export const db = mongoose.connection;
61
66
  export const closeMongo = () => {
62
67
  mongoose.connection.close(true);
63
68
  };
64
-
package/logs.ts CHANGED
@@ -26,4 +26,8 @@ const LogSchema = new Schema(
26
26
  { timestamps: true },
27
27
  );
28
28
 
29
- export default model<ILog>("Log", LogSchema);
29
+ const Log = model<ILog>("Log", LogSchema);
30
+
31
+ Log.ensureIndexes({ _id: 1, project: 1 });
32
+
33
+ export default Log;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brimble/models",
3
- "version": "1.4.14",
3
+ "version": "1.4.16",
4
4
  "description": "Brimble models",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/project.ts CHANGED
@@ -73,4 +73,8 @@ const projectSchema = new Schema(
73
73
  { timestamps: true },
74
74
  );
75
75
 
76
- export default model<IProject>("Project", projectSchema);
76
+ const Project = model<IProject>("Project", projectSchema);
77
+
78
+ Project.ensureIndexes({ _id: 1, updatedAt: 1, createdAt: 1 });
79
+
80
+ export default Project;
package/user.ts CHANGED
@@ -58,5 +58,9 @@ const userSchema: Schema = new Schema(
58
58
  },
59
59
  { timestamps: true },
60
60
  );
61
+ const User = model("User", userSchema);
61
62
 
62
- export default model<IUser>("User", userSchema);
63
+ // Create indexes for _id and email
64
+ User.ensureIndexes({ _id: 1, email: 1 });
65
+
66
+ export default User;