Question:
Hello everybody, i would like to delete several data in a database (for example called " TESTS").
how can i code this :
delete * from [tests] where [MONCRITERE]=“A supprimer”
Product:
Wix Editor
What are you trying to achieve:
I want to delete some (not all) data in my collection. by filter
-Bulkremove?
Thanks in advance
Generally, Wix does not use SQL for its CMS
To interact with the collections, use the WixData API
The query and bulkRemove methods may be what you are looking for
Query the items you want to remove, get their IDs and pass those to bulkRemove
Thanks for your answer. do you have an example please?
Not specifically, but the documentation should provide what you need
First we should start with the safe stuff, no deletion until we’re sure we got the correct records
backend/example.js
import wixData from 'wix-data-backend'
export function deleteTests() {
return wixData.query('Tests').eq('MONCRITERE', 'A supprimer').find()
}
When you run this function in your editor, the result should be something like this:
{
items: [...],
legnth: number,
...
}
Inspect the items returned and see if they are really all and only the records you want deleted
Then you can use those results:
const deleteIds = results.items.map(item => item._id)
wixData.bulkRemove('Tests', deleteIds)
1 Like
GREAT !!! Thanks a lot. it works perfectly. (i had to adapt a litlle bit but every thing is OK)
Have a nice day
2 Likes
Love the tip about making sure not to delete anything until you’ve checked you have the correct data 
Something that’s caught me out once or twice 
2 Likes