-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathinit-mongo.js
29 lines (24 loc) · 853 Bytes
/
init-mongo.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
function seed(dbName, user, password) {
db = db.getSiblingDB(dbName);
db.createUser({
user: user,
pwd: password,
roles: [{ role: 'readWrite', db: dbName }],
});
db.createCollection('api_keys');
db.createCollection('roles');
db.api_keys.insert({
metadata: 'To be used by the xyz vendor',
key: 'GCMUDiuY5a7WvyUNt9n3QztToSHzK7Uj',
version: 1,
status: true,
createdAt: new Date(),
updatedAt: new Date(),
});
db.roles.insertMany([
{ code: 'BUYER', status: true, createdAt: new Date(), updatedAt: new Date() },
{ code: 'SELLER', status: true, createdAt: new Date(), updatedAt: new Date() },
{ code: 'ADMIN', status: true, createdAt: new Date(), updatedAt: new Date() },
]);
}
seed('e-commerce-db', 'e-commerce-db-user', 'commerce');