Destroy method is dangerous
Node version: Sails version (sails): ORM hook version (sails-hook-orm): "sails-hook-orm": "2.1.1", Sockets hook version (sails-hook-sockets): Organics hook version (sails-hook-organics): Grunt hook version (sails-hook-grunt): Uploads hook version (sails-hook-uploads): DB adapter & version (e.g. [email protected]): "sails-postgresql": "1.0.1" Skipper adapter & version (e.g. [email protected]):
I just had a serious issue using the destroy method and wanted to share with you guys and see what can be done.
I know that the destroy method drops the table if passed empty object, and that is documented. I think this is a bad thing in and of itself.
The bigger issue is, and that's what caused my problem is that object doesn't have to be passed like this {} to cause the drop, it can go in like this Table.destroy({ id: undefined }). I'm pretty sure I even tested this case with one of the previous versions of the library and that it didn't use to work this way.
My suggestion is at the very least to document this case if not separate destroy and drop methods.
Hope this makes sense and thanks for the great work on this library. Let me know if I can help in any way.
Source: balderdashy/sails