【发布时间】:2015-04-23 02:17:16
【问题描述】:
我用微风创建了一个新条目,在提交时我想立即使用我用来创建记录的基本字段(例如使用电子邮件)获取记录的 ID,请问我如何使用获取新记录的 ID微风。
这就是我所做的
bind gotoStep2() with the save button which pass in the value of the textbox to use as predicate,
// the save() method successfully create the record to the database,
function gotoStep2(firstName, lastName, email) {
save();
console.log('Save log')
// Get the ProfileID
return datacontext.profile.getProfileId(firstName, lastName, email)
.then(function (data) {
console.log('Id retrived is: ' + data.Id); // check the value returned
vm.profile = data;
//$location.path('/step-two/' + data.Id);
// Todo: pass the value to the next route
}, function (error) {
logError('Unable to get speaker');
});
}
function getProfileId(firstName, lastName, email) {
var self = this;
var predicate = Predicate.create('firstName', '==', firstName)
.and('lastName', '==', lastName)
.and('email', '==', email);
var profiles = [];
return EntityQuery.from('Profiles')
.select('id')
.where(predicate)
.toType(entityName)
.using(self.manager).execute()
.then(querySucceeded, self._queryFailed);
function querySucceeded(data) {
profiles = data.results;
self.log('Retrieved [Profile by email] from remote data source', profiles.length, true);
return profiles;
}
}
从上面的查询并不总是得到任何返回值
谢谢
【问题讨论】:
-
我需要一个关于如何通过谓词查询来获取记录 id 的示例查询。
标签: breeze