gpt4 book ai didi

node.js - mongo 发现里面的 sails native 不工作

转载 作者:太空宇宙 更新时间:2023-11-04 00:45:41 25 4
gpt4 key购买 nike

我正在尝试使用 sails native 适配器直接在 mongo 上查询。尽管数据库中存在文档,但我没有得到任何结果。直接水线查找函数返回文档。不过,我想将 native 查找用于其他目的并尝试使其工作。有什么建议么?下面的输出:null []。

User.native(function(e,collection){
collection.find({phoneNumber:mPhoneNumber}).toArray(function(e,r){console.log(e,r);});

最佳答案

它成功了。似乎 orm native 在查询时不会将字符串格式的数字转换为整数。使用 parseInt 将 mPhoneNumber 转换为 Integer 并且它有效。

这是更新后的代码User.native(function(e,collection){ collection.find({phoneNumber:parseInt(mPhoneNumber)}).toArray(function(e,r){console.log(e,r);});

关于node.js - mongo 发现里面的 sails native 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34857635/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com