0

I create a model instance:

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

The returned instance in the callback contains all I need but ID, which I need to perform other actions where I need it to be inserted into another entity.

How is it supposed to work when I need to create a new model instance and use its ID to do something else?

Sergei Basharov
  • 51,276
  • 73
  • 200
  • 335

1 Answers1

0

Have you set the property idInjection": true in your Rental JSON?

This enables the ID prop on the create method:

{
    "name": "Rental",
    "plural": "rental",
    "base": "PersistedModel",
    "strict": true,
    "idInjection": true,
Andreas
  • 5,393
  • 9
  • 44
  • 53