-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy path20190401214506-userRoleAdd.js
55 lines (50 loc) · 1.1 KB
/
20190401214506-userRoleAdd.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
'use strict';
var dbm;
var type;
var seed;
/**
* We receive the dbmigrate dependency from dbmigrate initially.
* This enables us to not have to rely on NODE_PATH.
*/
exports.setup = function(options, seedLink) {
dbm = options.dbmigrate;
type = dbm.dataType;
seed = seedLink;
};
exports.up = function(db) {
let mClient;
return db.connection.connect(db.connectionString, { native_parser: true })
.then((mClientInst) => {
// mClientInst is an instance of MongoClient
mClient = mClientInst;
var p = mClient.collection('epic');
p.aggregate([
{
$match: { _schemaName: "User"}
}
])
.toArray()
.then(function (arr) {
for(let item of arr) {
p.update(
{
_id: item._id
},
{
$set: { read: ['staff', 'sysadmin'], write: ['staff', 'sysadmin'] }
});
}
mClient.close();
});
})
.catch((e) => {
console.log("e:", e);
mClient.close()
});
};
exports.down = function(db) {
return null;
};
exports._meta = {
"version": 1
};