knadh / localStorageDB

A simple database layer for localStorage and sessionStorage for creating structured data in the form of databases and tables
http://nadh.in/code/localstoragedb
814 stars 128 forks source link

Get the id of the last inserted record #15

Closed danbuntu closed 11 years ago

danbuntu commented 11 years ago

Hello

Is there a quick way to get the ID of the last inserted record? Or do I need to do an insert then a get all then get the highest ID?

knadh commented 11 years ago

The insert() function returns the last inserted id.

J06 commented 8 years ago

can you give the syntax using insert() function to get the id and store it in a variable?

knadh commented 8 years ago

var id = lib.insert("books", {code: "B001", title: "Phantoms in the brain", author: "Ramachandran", year: 1999, copies: 10});