xavierlacot / joli.js

joli.js is an Activerecord-like javascript ORM, particularly suited for being used in the Appcelerator Titanium Mobile framework.
MIT License
267 stars 60 forks source link

What happens if the field id is not actually named id but uid or something else #19

Open lbdremy opened 12 years ago

lbdremy commented 12 years ago

Hello Xavier, thanks for sharing this.

I wonder if the field id is not actually named id but uid or something else, does the lib works as expected? Because I expected when saving a new record that the save() method looks for if the record was already present in the database and in this case make a UPDATE query and not an INSERT query. The thing is in my case it's happening I get an error because joli tries to insert a row already existing and I wonder if that's because my field id as for name uid.

Could you give me an example showing how should users update a row in the database with convenient method like save.

Thanks for your help and time.

OwenMelbz commented 10 years ago

It wont work from what I've found, I've actually modified the joli core so it alloys when defining your model to set model.primary_key so everywhere then uses that. I recommend this for you if its a requirement!