@brimble/models 1.4.15 → 1.4.17
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.d.ts +4 -1
- package/dist/index.js +5 -2
- package/dist/logs.d.ts +2 -2
- package/dist/logs.js +3 -1
- package/dist/project.d.ts +2 -2
- package/dist/project.js +3 -1
- package/dist/user.d.ts +2 -3
- package/dist/user.js +4 -1
- package/index.ts +3 -2
- package/logs.ts +5 -1
- package/package.json +1 -1
- package/project.ts +5 -1
- package/user.ts +5 -1
package/dist/index.d.ts
CHANGED
|
@@ -14,4 +14,7 @@ export { GIT_TYPE, INTEGRATION_TYPE, OAUTH_PERMISSIONS, ENVIRONMENT, ROLES, PROJ
|
|
|
14
14
|
import mongoose from "mongoose";
|
|
15
15
|
export declare const connectToMongo: (mongoUrl: string) => Promise<void>;
|
|
16
16
|
export declare const db: mongoose.Connection;
|
|
17
|
-
export declare const closeMongo: (
|
|
17
|
+
export declare const closeMongo: (options?: {
|
|
18
|
+
restart: boolean;
|
|
19
|
+
url: string;
|
|
20
|
+
}) => void;
|
package/dist/index.js
CHANGED
|
@@ -68,7 +68,10 @@ const connectToMongo = (mongoUrl) => __awaiter(void 0, void 0, void 0, function*
|
|
|
68
68
|
});
|
|
69
69
|
exports.connectToMongo = connectToMongo;
|
|
70
70
|
exports.db = mongoose_1.default.connection;
|
|
71
|
-
const closeMongo = () => {
|
|
72
|
-
|
|
71
|
+
const closeMongo = (options) => {
|
|
72
|
+
if (options === null || options === void 0 ? void 0 : options.restart)
|
|
73
|
+
mongoose_1.default.connection.close(true, () => { (0, exports.connectToMongo)(options.url); });
|
|
74
|
+
else
|
|
75
|
+
mongoose_1.default.connection.close(true);
|
|
73
76
|
};
|
|
74
77
|
exports.closeMongo = closeMongo;
|
package/dist/logs.d.ts
CHANGED
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
|
-
|
|
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
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
|
-
|
|
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
|
|
3
|
-
|
|
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
|
-
|
|
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
|
@@ -63,6 +63,7 @@ export const connectToMongo = async (mongoUrl: string): Promise<void> => {
|
|
|
63
63
|
|
|
64
64
|
export const db = mongoose.connection;
|
|
65
65
|
|
|
66
|
-
export const closeMongo = () => {
|
|
67
|
-
mongoose.connection.close(true);
|
|
66
|
+
export const closeMongo = (options?: { restart: boolean, url:string }) => {
|
|
67
|
+
if (options?.restart) mongoose.connection.close(true, () => { connectToMongo(options.url); });
|
|
68
|
+
else mongoose.connection.close(true);
|
|
68
69
|
};
|
package/logs.ts
CHANGED
package/package.json
CHANGED
package/project.ts
CHANGED
|
@@ -73,4 +73,8 @@ const projectSchema = new Schema(
|
|
|
73
73
|
{ timestamps: true },
|
|
74
74
|
);
|
|
75
75
|
|
|
76
|
-
|
|
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
|
-
|
|
63
|
+
// Create indexes for _id and email
|
|
64
|
+
User.ensureIndexes({ _id: 1, email: 1 });
|
|
65
|
+
|
|
66
|
+
export default User;
|