Created
February 6, 2022 01:44
-
-
Save B4nan/003fedc741a4ae4243fc06696aabc4d6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// first partially load author entities | |
const r1 = await em.find(Author, {}, { fields: ['id'] }); | |
r1[0].email = 'lol'; // let's change one of the emails | |
console.log(r1[0].name); // undefined, not loaded | |
// reload full entities - no `refresh: true` needed! | |
const r2 = await em.find(Author, {}); | |
console.log(r2[0]); // fully loaded author entity, but `email` is changed to 'lol' | |
console.log(r1[0] === r2[0]); // true, same entity instance, just updated! | |
// flushing will now fire one update query to change the email of one author | |
await em.flush(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment