Node.js uses ORM2 to make Update action solutions that cannot modify solutions

Recently encountered a problem in the work, when using ORM2 for model modification, it is found that 2 SQL, the first time is performed when the associated field is updated. One time the value is changed to the value we expect, and the value will be changed into the original value for the second time.

After the autofetch is turned on, the associated model is automatically obtained. At this time, the model is:

  {RoomID: xxx, // associated Roomidroom: {/ Associated Room Object}}}}  
The first time will be modified according to the RoomID, the second time, according to the associated object Room of FETCH, resulted We saw the case of SQL twice.


Delete the object of the FETCH before Save operation.

for (VAR J IN Originentity) {IF (_.ISObject (Originentity [J])) {Delete Originentity [J];}} (Function) Err) {if (err) {return res. json ({errmsg: err [0] .msg});} Return Res. Json ({Code: 200, Data: Originentity});});

The above is the full content of this article, I hope this article will bring a certain help to everyone’s learning or work. If you have any questions, you can leave a message, thank you for your support of Tumi Cloud.

© Copyright Notice
Just support it if you like
comment Grab the couch

Please log in to comment