Files
wzdj/new/wz-api/scripts/mongo-local-practice.js

35 lines
1.1 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* 本地 Docker Mongowanzhi-mongodb 等)练手:创建库 + users 集合示例文档。
*
* 连接(与容器环境变量 MONGO_INITDB_ROOT_* 一致时):
* mongosh "mongodb://admin:admin123@127.0.0.1:27017/wanzhi_local?authSource=admin"
*
* 在 mongosh 内执行:
* load("e:/.../new/wz-api/scripts/mongo-local-practice.js")
*
* 说明wz-api 管理端「玩值用户列表」读的是 MySQL 表 wz_documentscoll='users'
* 不会读本脚本写入的 Mongo 集合;本脚本仅用于熟悉 Mongo / Compass / 与旧栈集合名对齐。
*/
const dbName = "wanzhi_local";
const collName = "users";
db = db.getSiblingDB(dbName);
db[collName].insertMany([
{
name: "练习用户",
phone: "13800138000",
// 以下为文档字段示意;玩值 HTTP 登录不走 Mongo 此密码
loginUsername: "admin",
loginPasswordPlain: "admin123",
status: "active",
isVip: false,
balance: 0,
createdAt: new Date(),
updatedAt: new Date(),
},
]);
print(`OK: ${dbName}.${collName} count = ${db[collName].countDocuments({})}`);