Last active
December 4, 2019 15:01
-
-
Save neuro-sys/1e00b5862059aca2ca26553b7aa18e35 to your computer and use it in GitHub Desktop.
Comparison of Sequelize and TypeORM high-level (simplest) APIs and the generated SQLs
This file contains 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
////////////////////////// TEST ///////////////////////// | |
console.log('* Finding original document'); | |
const myentitySet = await repository.findOneOrFail({ | |
select: [ 'id', 'version' ], | |
where: { id: params.id }, | |
}); | |
console.log('* Found original document'); | |
Object.assign(myentitySet, { | |
name: 'fooobar123', | |
}); | |
console.log('* Saving'); | |
await repository.save(myentitySet); | |
console.log('* Saved'); | |
////////////////////////// TEST END ///////////////////////// |
This file contains 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
* Finding original document | |
query: SELECT "MyentitySet"."version" AS "MyentitySet_version", "MyentitySet"."id" AS "MyentitySet_id" FROM "myentity_set" "MyentitySet" WHERE "MyentitySet"."id" = $1 LIMIT 1 -- PARAMETERS: ["5de5344692e53373f9cc0b9c"] | |
* Found original document | |
* Saving | |
query: SELECT "MyentitySet"."correlation_id" AS "MyentitySet_correlation_id", "MyentitySet"."editor" AS "MyentitySet_editor", "MyentitySet"."created_at" AS "MyentitySet_created_at", "MyentitySet"."updated_at" AS "MyentitySet_updated_at", | |
"MyentitySet"."archived_at" AS "MyentitySet_archived_at", "MyentitySet"."version" AS "MyentitySet_version", "MyentitySet"."id" AS "MyentitySet_id", "MyentitySet"."name" AS "MyentitySet_name", "MyentitySet"."omitted" AS | |
"MyentitySet_omitted", "MyentitySet"."omitted" AS "MyentitySet_omitted", "MyentitySet"."omitted", "MyentitySet"."omitted" AS "MyentitySet_omitted", "MyentitySet"."omitted" AS "MyentitySet_omitted", "MyentitySet"."omitted_id" AS | |
"MyentitySet_omitted_id", "MyentitySet"."omitted" AS "MyentitySet_omitted", "MyentitySet"."omitted" AS "MyentitySet_omitted" FROM "myentity_set" "MyentitySet" WHERE "MyentitySet"."id" IN ($1) -- PARAMETERS: | |
["5de5344692e53373f9cc0b9c"] | |
query: START TRANSACTION | |
query: UPDATE "myentity_set" SET "name" = $2, "version" = "version" + 1, "updated_at" = CURRENT_TIMESTAMP WHERE "id" IN ($1) RETURNING "updated_at", "version" -- PARAMETERS: ["5de5344692e53373f9cc0b9c","fooobar123"] | |
query: COMMIT | |
* Saved |
This file contains 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
////////////////////////// TEST ///////////////////////// | |
console.log('* Finding original document'); | |
const myentitySet = await MyentitySet.findOne({ | |
where: { | |
id: '5dc1629536578e63c0e44811', | |
}, | |
attributes: ['_id', 'version'], | |
}); | |
console.log('* Found original document'); | |
Object.assign(myentitySet, { | |
name: 'fooobar123', | |
}); | |
console.log('* Saving'); | |
await myentitySet.save(); | |
console.log('* Saved'); | |
////////////////////////// TEST END ///////////////////////// |
This file contains 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
* Finding original document | |
Executing (default): SELECT "id" AS "_id", "version" FROM "myentity_sets" AS "myentity_set" WHERE ("myentity_set"."archived_at" IS NULL AND "myentity_set"."id" = '5dc1629536578e63c0e44811') LIMIT 1; | |
* Found original document | |
* Saving | |
Executing (default): UPDATE "myentity_sets" SET "name"=$1,"updated_at"=$2,"version"=$3 WHERE "version" = $4 AND "id" = $5 | |
* Saved |
This file contains 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
[typeorm] $ grep -R -n --color -i todo src/ | wc -l | |
207 | |
[sequelize] $ grep -R -n --color -i todo lib/ | wc -l | |
9 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment