How to delete all data from multiple Baqend tables?

I need to delete all rows from multiple tables, programmatically (not in the toolbar). Is there an API for this? I could not find it in the documentation .

+4
source share
1 answer

You are correct, this is not currently documented. However, you can find the REST call in our API Explorer , although you are not getting syntactic sugar from the JS SDK. Call REST: DELETEto /db/{bucket}, where bucketis the name of the table to be deleted. Using the JS SDK, this request is wrapped in a message object TruncateBucket, you can use it as follows:

    DB.login("userWithAdminRole", "<password>").then(function() {
        return DB.send(new DB.message.TruncateBucket('<table>'));
    }).then(function () {
        console.log('truncated!');
    }).catch(function() {
        console.log('catch truncated!');
    });

. , (, DB.login). backend module ( node), .


REST API Explorer. :

API Explorer

+2

Source: https://habr.com/ru/post/1660278/


All Articles