Core: Last inserted ID or record

Created on 9 Aug 2016  路  3Comments  路  Source: adonisjs/core

In Laravel when saving any record via elaquent, it also return save data. How to achieve this in adonis?

Most helpful comment

It's actually pretty simple:

* createRole () {
  role = new Role();
  role.name = "New Role";
  yield role.save();
  console.log(role);
  return role;
}

Variable role after yield role.save() will contain the last inserted id and other associated properties.

All 3 comments

Is there any solution? Thanks.

It's actually pretty simple:

* createRole () {
  role = new Role();
  role.name = "New Role";
  yield role.save();
  console.log(role);
  return role;
}

Variable role after yield role.save() will contain the last inserted id and other associated properties.

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

blendsoft picture blendsoft  路  3Comments

aligoren picture aligoren  路  4Comments

codingphasedotcom picture codingphasedotcom  路  3Comments

begueradj picture begueradj  路  3Comments

itsg2jakhmola picture itsg2jakhmola  路  3Comments