回送hasMany关系在mongodb上不起作用

编程入门 行业动态 更新时间:2024-10-24 06:33:27
本文介绍了回送hasMany关系在mongodb上不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

从RedHat linux迁移到AWS上的SUSE之后,我有一些奇怪的行为.

I have some strange behavior after moving from RedHat linux to SUSE on AWS.

之前一切正常.

这是我的关系:

类别:

{ "name": "Category", "plural": "categories", "base": "PersistedModel", "relations": { ... "professions": { "type": "hasMany", "model": "Profession", "foreignKey": "" } } }

专业

{ "name": "Profession", "plural": "professions", "base": "PersistedModel", "relations": { ... "category": { "type": "belongsTo", "model": "Category", "foreignKey": "" } } }

问题是,当我更新现有的专业时:

The problem is that when I update an existing profession with:

{ "categoryId" : "..." }

当我请求/api/categories/{id}/professions

It doesn't work when I request /api/categories/{id}/professions

但是/api/profession/{id}/category可以正常工作.

But /api/profession/{id}/category works fine.

此外,如果我创建新的职业,例如:

Also if I create new Profession like:

{ "name" : "TEST", "categoryId" : "..." }

两种方法都可以正常工作.

It works fine both ways.

Category.professions.create({名称:"TEST2"});也可以正常工作.

Category.professions.create({ name: "TEST2" }); Works fine as well.

我在AWS上使用RedHat linux.现在,我在AWS上使用SUSE linux.

I was using RedHat linux on AWS. Now I am using SUSE linux on AWS.

Mongo数据库版本:数据库版本v3.0.7

Mongo db version : db version v3.0.7

node --version v5.4.1 npm --version 3.3.12 npm list loopback `-- loopback@2.26.2

我试图通过/explorer面板和代码对其进行更新.

I tried to update it from /explorer panel and code.

在代码中(角度),我这样做:

in code (angular) I do this:

Profession.prototype$updateAttributes( { id: toAdd[i] }, { categoryId: catId });

正如我所说,所有代码都可以在运行RDHE的测试服务器上运行. 我将检查mongo日志,但我安装了相同的mongo版本并使用相同的mongo.config

And as I said, all the code works on test server running RDHE. I will check mongo logs, but I installed the same mongo version and using same mongo.config

推荐答案

Okey ...所以问题出在以下两个模块之一或两个:

Okey... so the problem was one or both of these modules:

"loopback-connector-mongodb": "^1.13.0" "loopback-datasource-juggler": "^2.39.0"

由于版本号写为^#.#.#,表示版本更高但兼容. 但是其中之一无法正常工作: github/strongloop/loopback/issues/274

Since the version number is written as ^#.#.# it means higher but compatible. But one of them wasn't working: github/strongloop/loopback/issues/274

这引起了所有问题.

简单的解决方案:

"loopback-connector-mongodb": "1.13.0" "loopback-datasource-juggler": "2.39.0"

我刚刚安装了我知道可以使用的版本.

I just installed the versions which i know that works.

更多推荐

回送hasMany关系在mongodb上不起作用

本文发布于:2023-11-22 13:07:09,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1617533.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:上不   关系   回送   hasMany   mongodb

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!