0
votes

We have been using breeze for the past year in our project and are quite happy with it. Previously our server was a asp.net application with entity framework. Now we are moving toward node.js and mysql. We have installed breeze-sequelize package and everything is working fine.

The documentation breeze Node server w/sequelize, says that the result of a query is a promise with the resolved result formatted so that it can be directly returned to the breeze client. And this is effectively what happens: the result of a query is just a plain old json object with values from the database, not entities the way breeze understand entities.

My question is this: I have a scenario where a heavy server process is instantiated by the client. No data is expected in the client. The process will run entirely on the server, make queries, modify data and then save them, all in the server. How can I transform those plain old json objects into entities during my process, I would like to know for example what object has been modified, what have been deleted and send appropriate message to the client.

Of course I could create myself a kind of mechanism that will track changes in my objects but I would rather rely on the breeze manager for that.

Should I create a breeze manager in the server?

var manager = new breeze.EntityManager(...)

A second concern is: with breeze-sequelize I do we handle transactions? start-transaction, complte-transaction and rollback-transaction?

Thank you for your input

1

1 Answers

0
votes

To turn JSON with the attribute values of a Sequelize instance into an actual Instance use:

Model.build({ /* attributes-hash */ }, { isNewRecord: false })

For an example demonstrating this see here. The Sequelize Instance documentation (here, see especially the function changed) might also be helpful. I am not familiar with Breeze and might have misunderstood your question here, does this help?