You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Answer: It deletes every User in your database, because delete doesn't take FindOptions, and therefore the where key appears to be completely ignored.
This is easily avoidable by using it as the documentation says, and instead doing delete(User, { name: "Omar" }); but since TypeScript won't tell you that you're doing anything wrong due to the overly general types, my team is finding this to be a particularly volatile API choice for TypeORM to not warn against.
Better would be stricter types to forbid usage of keys that aren't a part of User, but as a general complaint, wish the TypeORM APIs just generally had stricter enforcement of a consistent API invocation syntax.
The text was updated successfully, but these errors were encountered:
Issue type:
[x] question
[ ] bug report
[ ] feature request
[ ] documentation issue
Database system/driver:
[ ]
cordova
[ ]
mongodb
[ ]
mssql
[ ]
mysql
/mariadb
[ ]
oracle
[x]
postgres
[ ]
cockroachdb
[ ]
sqlite
[ ]
sqljs
[ ]
react-native
[ ]
expo
TypeORM version:
[x]
latest
[ ]
@next
[ ]
0.x.x
(or put your version here)Steps to reproduce or a small repository showing the problem:
If you do this, what happens?
Answer: It deletes every
User
in your database, becausedelete
doesn't takeFindOptions
, and therefore thewhere
key appears to be completely ignored.This is easily avoidable by using it as the documentation says, and instead doing
delete(User, { name: "Omar" })
; but since TypeScript won't tell you that you're doing anything wrong due to the overly general types, my team is finding this to be a particularly volatile API choice for TypeORM to not warn against.Better would be stricter types to forbid usage of keys that aren't a part of
User
, but as a general complaint, wish the TypeORM APIs just generally had stricter enforcement of a consistent API invocation syntax.The text was updated successfully, but these errors were encountered: