gpt4 book ai didi

mysql - Nodejs breeze-sequelize with MySQL - .select() 不工作

转载 作者:行者123 更新时间:2023-11-28 23:34:00 25 4
gpt4 key购买 nike

我使用的是 breeze-sequelize 版本 0.0.18。当我尝试在 entityQuery 上使用 select() 时,出现奇怪的错误 _.pluck is not a function。如果我删除 .select(),它将正常工作。

我的 breeze 查询如下所示:

var predicate = Predicate.create('transactionDate', '>=', fromDate);
var entityQuery = EntityQuery.from('Transactions')
.where(predicate)
.select('transactionDate');
var sequelizeQuery = new SequelizeQuery(api.db, entityQuery);
return sequelizeQuery.execute();

返回时,我得到的错误是:

TypeError: _.pluck is not a function
at SequelizeQuery.<anonymous> (/Users/shu/Documents/project/node_modules/breeze-sequelize/SequelizeQuery.json.js:143:39)
at Array.map (native)
at SequelizeQuery._processSelect (/Users/shu/Documents/project/node_modules/breeze-sequelize/SequelizeQuery.json.js:136:56)
at SequelizeQuery._processQuery (/Users/shu/Documents/project/node_modules/breeze-sequelize/SequelizeQuery.json.js:72:8)
at new SequelizeQuery (/Users/shu/Documents/project/node_modules/breeze-sequelize/SequelizeQuery.json.js:43:23)
at getTransactions (/Users/shu/Documents/project/src/server/api/admin.controller.js:189:26)

出于好奇,我查看了我的 breeze-sequelize 库中的函数 SequelizeQuery._processSelect。错误来自 return usesNameOnServer ? pp : _.pluck(props, "nameOnServer").join(".");.

SequelizeQuery.prototype._processSelect = function() {
var selectClause = this.entityQuery.selectClause;
var usesNameOnServer = this.entityQuery.usesNameOnServer;
if (selectClause == null) return;
// extract any nest paths and move them onto the include
var navPropertyPaths = [];
this.sqQuery.attributes = selectClause.propertyPaths.map(function(pp) {
var props = this.entityType.getPropertiesOnPath(pp, usesNameOnServer, true);
var isNavPropertyPath = props[0].isNavigationProperty;
if (isNavPropertyPath) {
this._addInclude(this.sqQuery, props);
}
if (isNavPropertyPath) return null;
return usesNameOnServer ? pp : _.pluck(props, "nameOnServer").join(".");
}, this).filter(function(pp) {
return pp != null;
});
}

有人可以帮助我吗?谢谢!

最佳答案

_.pluck 函数来自lodash , lodash 在 4.0 版本中移除了 pluck 功能

breeze-sequelize 库最终会更新到 lodash 4,但与此同时,请尝试使用 lodash 3.x。

关于mysql - Nodejs breeze-sequelize with MySQL - .select() 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36361718/

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