forked from all_user/stat_center
初始化
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
// Insert backend admin "fish01" into the `admin` collection.
|
||||
// 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_admin_fish01.js
|
||||
//
|
||||
// Schema mirrors models/adminMod/type.go (Admin struct).
|
||||
|
||||
const now = new Date();
|
||||
const secret = "FISHADMIN" + Math.random().toString(36).slice(2, 12).toUpperCase();
|
||||
|
||||
const doc = {
|
||||
account: "fish01",
|
||||
password: "fish01",
|
||||
name: "fish01",
|
||||
roleId: NumberLong(1),
|
||||
token: "",
|
||||
status: NumberLong(0),
|
||||
secret: secret,
|
||||
hasBind: false,
|
||||
MerchantId: "",
|
||||
blocRole: 0,
|
||||
createdAt: now,
|
||||
updatedAt: now,
|
||||
lastTime: now,
|
||||
};
|
||||
|
||||
const existing = db.admin.findOne({ account: doc.account });
|
||||
if (existing) {
|
||||
print("admin '" + doc.account + "' already exists, skipping insert:");
|
||||
printjson(existing);
|
||||
} else {
|
||||
const res = db.admin.insertOne(doc);
|
||||
print("inserted:");
|
||||
printjson(res);
|
||||
printjson(db.admin.findOne({ account: doc.account }));
|
||||
}
|
||||
Reference in New Issue
Block a user