coresmart / persistencejs

persistence.js is an asynchronous Javascript database mapper library. You can use it in the browser, as well on the server (and you can share data models between them).
http://persistencejs.org
1.73k stars 240 forks source link

Primary Key always null #155

Open paul-piro opened 9 years ago

paul-piro commented 9 years ago

i have the following table

this.createTable('Agency', function(t){ t.text('name'); t.text('username'); t.text('password'); t.text('currency'); t.integer('balance'); t.integer('oldbalance'); });

when i try to insert into the table like this

this.executeSql('INSERT INTO Agency (name, username, password, currency, balance, oldBalance) VALUES ("agency", "username", "pass", "USD", 0, 0)');

the primary key for 3 records i have is always null, and why is the primary key varchar(32) it should be integer?

crico commented 9 years ago

Persistencejs manages primary keys for you; it generates an ID - varchar(32) (like a MD5) - internally. If you are using executeSql, I think that you should add an ID field to the query with a MD5 value.