$inc is not working in embedded object loopback 3
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 25/100
- Issue 类型
- 缺陷
- 描述清晰度
- 需要澄清
- 活跃度
- 停滞
- 技术栈
- javascript
- 领域
- database
调研方向
从 Item.json 中的 embedsMany 关系和嵌入式 schema BranchWiseAvailableQtyE 开始,然后使用所示的 $inc 值,在调用 branchWiseAvailableQtyE.set 时重现验证错误。跟踪嵌入式对象更新的验证方式,并确定是否支持递增 availableQty 以及添加缺失的对象;当支持的行为或所需的更改得到明确确立时,即视为完成。
由索引模型根据 Issue 内容生成。
描述
I am using loopback 3. In which I have model Item and that have embedded object availableQtyBranchWise. I was trying to update the availableQtyBranchWise using $inc but with this operator i got validation error.
Item.json
{
"name": "Item",
"base": "PersistedModel",
"idInjection": true,
"options": {
"validateUpsert": true,
"strictObjectIDCoercion": true
},
"properties": {
"name": {
"type": "string"
},
"barcode": {
"type": "number"
}
},
"relations": {
"branchWiseAvailableQtyE": {
"type": "embedsMany",
"model": "BranchWiseAvailableQtyE",
"property": "branchWiseAvailableQty",
"options": {
"validate": false,
"forceId": true
},
"description": "branchWiseAvailableQtyE is used to store branch wise available quantity"
}
}
}
Branch Wise Available Qty Embedded Schema
{
"name": "BranchWiseAvailableQtyE",
"base": "Model",
"idInjection": true,
"options": {
"validateUpsert": true
},
"properties": {
"refBranchName": {
"type": "string",
"required": true
},
"refBranchId": {
"type": "string",
"required": true
},
"refBranchCode": {
"type": "string",
"required": true
},
"availableQty": {
"type": "number",
"required": true,
"default": 0
}
},
"validations": [],
"relations": {},
"acls": [],
"methods": {}
}
In DB Data should look like
{
"_id": {
"$oid": "66e90d94c2d97907244dfae0"
},
"name": "01 PlK 1 1000 SERIES",
"branchWiseAvailableQty": [
{
"refBranchName": "Delhi",
"refBranchId": {
"$oid": "6204c8d8e1300e2ea8420483"
},
"refBranchCode": "DL",
"availableQty": 20,
"id": {
"$oid": "f3ef503f555877c69cc8ed6a"
}
},
{
"refBranchName": "Mumbai",
"refBranchId": {
"$oid": "6204c8d8e1340e2ea8420483"
},
"refBranchCode": "MU",
"availableQty": 40,
"id": {
"$oid": "f3ef503f555987c69cc8ed6a"
}
}
],
"barcode": 1856
}
I was trying to increment, decrement availableQty when object exists and add object when does not exist.
This is my code where I update the availableQty
item.branchWiseAvailableQtyE.set(ObjectId(f3ef503f555987c69cc8ed6a),{ availableQty: {$inc: 10}}, null, function(err, result) {
if (err) {
return reject(err);
}
return resolve(result);
});
This give me validation error because I am using
{ availableQty: {$inc: 10}}
But If I use this syntax it works
{ availableQty: 10}
Please help me. Thanks, in advance
- 主要语言
- JavaScript
- 星标
- 279
- 派生
- 362
- 平均合并
- 21 小时 14 分钟
- 30 天内合并 PR
- 16
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
loopbackio/loopback-datasource-juggler 的其他 Issue
-
Breaking changes for `loopback-datasource-juggler@7` not listed anywhere可能重新可做 @dhmlau 于 158 天前认领,目前没有进行中的 PR。 未关闭bug
loopbackio/loopback-datasource-juggler#2548 · 1 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
-
难度 3/5 1-2 天 新手友好度 68/100
loopbackio/loopback-datasource-juggler#2530 ·
维护者通常 1 天内回复
-
allow empty array in createAll可能已有人在做 @ajay-prajapati07 于 533 天前认领。 未关闭feature
难度 3/5 1-2 天 新手友好度 45/100
loopbackio/loopback-datasource-juggler#2409 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 55/100
loopbackio/loopback-datasource-juggler#1968 ·
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 15/100
loopbackio/loopback-datasource-juggler#1917 ·
维护者通常 1 天内回复
查看 loopbackio/loopback-datasource-juggler 的全部 Issue
相似的 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 63/100
anothaDev/luci-theme-vantage#143 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
kingcharleslzy-ai/dsh-purge#282 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 72/100
-
a-corriger bug
难度 2/5 1-3 小时 新手友好度 86/100
christian-raj/S-Aloha#340 ·
-
area:image documentation good first issue
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 1 天内回复