dresende / node-orm2

Object Relational Mapping
http://github.com/dresende/node-orm2
MIT License
3.07k stars 377 forks source link

Get Last Insert ID on create method #534

Open shoaibmerchant opened 10 years ago

shoaibmerchant commented 10 years ago

I am using MySQL as the database with the orm and my Primary Key is set as Auto-Increment. Is there any way to retrieve the last Insert ID on create for the PK or any existing implementation that would help.

n1c commented 9 years ago

+1

The idea of a single create, instead of the create that expects an array is very handy. Specifically because you can then just return the created object (ID and all).

Person.create({ name: "John", surname: "Doe" }, function (err, John) {
    // John.id is set.
});
darkpixel commented 8 years ago

+1