compass-user-model 2.0.0 → 2.1.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.
- package/index.js +1 -1
- package/lib/model.js +13 -19
- package/package.json +6 -7
package/index.js
CHANGED
package/lib/model.js
CHANGED
@@ -1,23 +1,17 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
const Model = require('ampersand-model');
|
2
|
+
const storageMixin = require('storage-mixin');
|
3
|
+
const uuid = require('uuid');
|
4
|
+
const compassUtils = require('@mongodb-js/compass-utils');
|
5
|
+
const basepath = (compassUtils.getStoragePaths() || {}).basepath;
|
4
6
|
|
5
|
-
|
6
|
-
try {
|
7
|
-
electronApp = require('@electron/remote').app;
|
8
|
-
} catch (e) {
|
9
|
-
/* eslint no-console: 0 */
|
10
|
-
console.log('Could not load @electron/remote', e.message);
|
11
|
-
}
|
7
|
+
// const debug = require('debug')('scout:user');
|
12
8
|
|
13
|
-
|
14
|
-
|
15
|
-
var User = Model.extend(storageMixin, {
|
9
|
+
const User = Model.extend(storageMixin, {
|
16
10
|
idAttribute: 'id',
|
17
11
|
namespace: 'Users',
|
18
12
|
storage: {
|
19
13
|
backend: 'disk',
|
20
|
-
basepath:
|
14
|
+
basepath: basepath
|
21
15
|
},
|
22
16
|
props: {
|
23
17
|
id: {
|
@@ -43,8 +37,8 @@ var User = Model.extend(storageMixin, {
|
|
43
37
|
}
|
44
38
|
});
|
45
39
|
|
46
|
-
User.getOrCreate =
|
47
|
-
|
40
|
+
User.getOrCreate = (id) => new Promise((resolve, reject) => {
|
41
|
+
const user = new User({
|
48
42
|
id: id || uuid.v4(),
|
49
43
|
createdAt: new Date()
|
50
44
|
});
|
@@ -53,12 +47,12 @@ User.getOrCreate = function(id, done) {
|
|
53
47
|
user.save({
|
54
48
|
lastUsed: new Date()
|
55
49
|
});
|
56
|
-
|
50
|
+
resolve(user);
|
57
51
|
},
|
58
52
|
error: function(model, err) {
|
59
|
-
|
53
|
+
reject(err);
|
60
54
|
}
|
61
55
|
});
|
62
|
-
};
|
56
|
+
});
|
63
57
|
|
64
58
|
module.exports = User;
|
package/package.json
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
"name": "compass-user-model",
|
3
3
|
"description": "MongoDB user model.",
|
4
4
|
"author": "Lucas Hrabovsky <lucas@mongodb.com>",
|
5
|
-
"version": "2.
|
5
|
+
"version": "2.1.1",
|
6
6
|
"bugs": {
|
7
7
|
"url": "https://jira.mongodb.org/projects/COMPASS/issues",
|
8
8
|
"email": "compass@mongodb.com"
|
@@ -40,21 +40,20 @@
|
|
40
40
|
"ampersand-state": "5.0.3",
|
41
41
|
"debug": "^2.2.0",
|
42
42
|
"lodash.get": "^4.4.2",
|
43
|
-
"mongodb-collection-model": "^5.
|
44
|
-
"mongodb-database-model": "^2.
|
43
|
+
"mongodb-collection-model": "^5.1.1",
|
44
|
+
"mongodb-database-model": "^2.1.1",
|
45
45
|
"mongodb-ns": "^2.4.0",
|
46
46
|
"raf": "^3.4.1",
|
47
|
-
"storage-mixin": "^5.
|
47
|
+
"storage-mixin": "^5.1.0",
|
48
48
|
"uuid": "^3.3.2"
|
49
49
|
},
|
50
50
|
"devDependencies": {
|
51
|
-
"@
|
51
|
+
"@mongodb-js/compass-utils": "^0.1.1",
|
52
52
|
"depcheck": "^1.4.1",
|
53
|
-
"electron": "^15.5.7",
|
54
53
|
"eslint": "^7.25.0",
|
55
54
|
"eslint-config-mongodb-js": "^3.0.1",
|
56
55
|
"lodash.result": "^4.5.2",
|
57
56
|
"mocha": "^6.0.2"
|
58
57
|
},
|
59
|
-
"gitHead": "
|
58
|
+
"gitHead": "51f04a0ac45c3b51a3ffb98af390c811d1404380"
|
60
59
|
}
|