PhilWaldmann / openrecord

Make ORMs great again!
https://openrecord.js.org
MIT License
486 stars 38 forks source link

How can I set primary key? #58

Closed netonrails closed 6 years ago

netonrails commented 6 years ago

Some of my tables use 'bar_code' instead of 'id' for primary key name. and varchar type.

This case,

.. model.bar_code = req.body.bar_code; //--- user input value but "0" ..

model.save(function() { model.bar_code === "0" //--- true!!! }

How can I avoid this problem?

PhilWaldmann commented 6 years ago

Hi @netonrails

sorry for the delay! What database do you use? Are there any validation errors (console.log(model.errors))?

If there is some autoincrement value defined in the database openrecord will not take any input for that field.