2016-11-09 54 views
0

我创建了一个模型实例:获取ID在.create([数据],CB)回调在环回

Rental.create({ 
     user: 'john', 
     period: 4 
    }, (err, rental) => { 
     // is it possible to get rental id here? 
    }); 

的回调返回的实例包含了所有我需要的,但ID,这是我需要执行我需要将其插入另一个实体的其他操作。

当我需要创建一个新的模型实例并使用其ID来做其他事情时,它应该如何工作?

+0

是'Rental'猫鼬模式?或者是什么? –

+0

这是一个环回模型 –

回答

0

您是否在Rental JSON中设置了属性idInjection": true

这使得在创建方法的ID道具:

{ 
    "name": "Rental", 
    "plural": "rental", 
    "base": "PersistedModel", 
    "strict": true, 
    "idInjection": true,