Search code examples
mysqlnode.jsdatabasegoogle-cloud-platformgoogle-cloud-spanner

Delete record from database with Cloud Spanner


In the Node.js example in the Cloud Spanner docs, I learned how to query, read, insert and update record from my Cloud Spanner database. But I don't know how to 'delete' record.

Since the insertion and update method is just 'tablename.insert(...)' and'tablename.update(...)', I tried 'tablename.delete(...)' but it deleted the table itself. I want to delete record... Seems like DML statements doesn't work in query.

How can I delete record from database with Google's Cloud Spanner?


Solution

  • You want deleteRows.

    var keys = ['Id1', 'Id2', 'Id3'];
    tablename.deleteRows(keys, function(err, apiResponse) {});
    

    Link docs: Google Cloud Node ⇒ Cloud Spanner ⇒ Table ⇒ deleteRows