File size: 371 Bytes
24fd742 |
1 2 3 4 5 6 7 8 9 10 11 12 13 |
// MongoDB初始化脚本
db = db.getSiblingDB('chatapp');
// 创建用户集合索引
db.users.createIndex({ "email": 1 }, { unique: true });
db.users.createIndex({ "username": 1 }, { unique: true });
// 创建消息集合索引
db.messages.createIndex({ "timestamp": -1 });
db.messages.createIndex({ "room": 1, "timestamp": -1 });
print('数据库初始化完成');
|