forked from all_user/stat_center
初始化
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
// Insert authority role with _id=1 (used by admin fish01).
|
||||
// Run:
|
||||
// mongosh "mongodb://stat_center:v5weEdNvXnJCMr9TeFFm@172.104.52.130:27017,172.104.52.26:27017,172.104.52.242:27017/stat_center?authSource=stat_center&replicaSet=fish0" script/add_role_1.js
|
||||
//
|
||||
// Schema mirrors models/authorityMod/type.go (Authority struct).
|
||||
|
||||
const now = new Date();
|
||||
|
||||
const doc = {
|
||||
_id: NumberLong(1),
|
||||
role: "super_admin",
|
||||
authJson: "*",
|
||||
createdAt: now,
|
||||
updatedAt: now,
|
||||
};
|
||||
|
||||
const existing = db.authority.findOne({ _id: doc._id });
|
||||
if (existing) {
|
||||
print("authority role _id=1 already exists, skipping insert:");
|
||||
printjson(existing);
|
||||
} else {
|
||||
const res = db.authority.insertOne(doc);
|
||||
print("inserted:");
|
||||
printjson(res);
|
||||
printjson(db.authority.findOne({ _id: doc._id }));
|
||||
}
|
||||
Reference in New Issue
Block a user