【发布时间】:2017-01-09 04:03:26
【问题描述】:
我正在使用 Nodejs,我有一个查询来获取计数。我想检查 count > 0 是否返回 true,否则 - false。
但我无法使用 nodejs 处理它。
这是我的代码:
const uidIsConnection = (model, entityId, uid) =>
models[model].count({
where: { entityId, profileId: uid }
});
var data = uidIsConnection('ProfileData', user.id, id);
//I want this variable data to have the value of true or false
现在,data 返回承诺:
Promise {
_bitField: 2097152,
_fulfillmentHandler0: undefined,
_rejectionHandler0: undefined,
_promise0: undefined,
_receiver0: undefined,
_boundTo: profiledata }
如何根据count > 0而不是promise返回布尔值?
【问题讨论】:
标签: javascript node.js sequelize.js