ccccccc / mongo-init.js
cnmksjs's picture
Upload 49 files
24fd742 verified
raw
history blame contribute delete
371 Bytes
// 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('数据库初始化完成');