backend/generate/database/mongo/2025100900000001_permission...

19 lines
710 B
Plaintext
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.

// 1. 唯一索引:權限名稱必須唯一
db.permission.createIndex({"name": 1}, {unique: true});
// 2. 複合唯一稀疏索引HTTP 路徑 + 方法的組合必須唯一(用於 API 權限)
db.permission.createIndex({"http_path": 1, "http_method": 1}, {unique: true, sparse: true});
// 3. 查詢索引:按狀態查詢
db.permission.createIndex({"status": 1});
// 4. 查詢索引:按父 ID 查詢(用於獲取子權限)
db.permission.createIndex({"parent_id": 1});
// 5. 複合索引:按類型和狀態查詢(常用組合)
db.permission.createIndex({"type": 1, "status": 1});
// 6. 時間戳索引:用於排序和時間範圍查詢
db.permission.createIndex({"create_time": 1});