Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
31b723839e | ||
|
|
1f48a02083 | ||
|
|
0f2b4d6428 |
+1
-4
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "shrimp-server",
|
"name": "shrimp-server",
|
||||||
"version": "0.7.6",
|
"version": "0.7.11",
|
||||||
"description": "Shrimp 框架后端 — 声明式字段驱动的 Node.js 管理后台框架(Express + Mongoose + JWT)",
|
"description": "Shrimp 框架后端 — 声明式字段驱动的 Node.js 管理后台框架(Express + Mongoose + JWT)",
|
||||||
"main": "dist/main/index.js",
|
"main": "dist/main/index.js",
|
||||||
"types": "dist/main/index.d.ts",
|
"types": "dist/main/index.d.ts",
|
||||||
@@ -55,8 +55,5 @@
|
|||||||
"tsx": "^4.7.0",
|
"tsx": "^4.7.0",
|
||||||
"typescript": "^5.3.0",
|
"typescript": "^5.3.0",
|
||||||
"vitest": "^1.4.0"
|
"vitest": "^1.4.0"
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"shrimp-server": "git+http://git.zeromvc.com/wc24/shrimp-server.git#v0.7.4"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -79,9 +79,10 @@ export class MongoShrimpCrud<T> implements ShrimpCrud<T> {
|
|||||||
const allRefIds = new Set<string>()
|
const allRefIds = new Set<string>()
|
||||||
for (const item of items) {
|
for (const item of items) {
|
||||||
const val = (item as any)[pop.key]
|
const val = (item as any)[pop.key]
|
||||||
|
// 跳过空串:可选 Relation 常存 "",混进 { _id: { $in } } 会让 Mongoose 转 ObjectId 抛 CastError、整页 500。
|
||||||
if (Array.isArray(val)) {
|
if (Array.isArray(val)) {
|
||||||
val.forEach((id: any) => { if (id != null) allRefIds.add(String(id)) })
|
val.forEach((id: any) => { if (id != null && id !== "") allRefIds.add(String(id)) })
|
||||||
} else if (val != null) {
|
} else if (val != null && val !== "") {
|
||||||
allRefIds.add(String(val))
|
allRefIds.add(String(val))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ describe("crudRegistry 自动登记", () => {
|
|||||||
await productCrud.add({ code: "P001", tagIds: [t1._id, t2._id] } as any)
|
await productCrud.add({ code: "P001", tagIds: [t1._id, t2._id] } as any)
|
||||||
|
|
||||||
const result = await productModule.list({})
|
const result = await productModule.list({})
|
||||||
expect((result.list[0] as any).tagIds_label).toEqual(["热门", "促销"])
|
// _label 逐行机制已退场:relation 显示名走整页 refs 字典(refs[moduleKey][id])
|
||||||
|
expect((result as any).refs?.tag).toEqual({ [t1._id]: "热门", [t2._id]: "促销" })
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user