How does one delete the last document in a collection through firebase functions trigger?
I am trying to delete a document that I don't have a reference to. I just want to delete the last document using order by the descending and limiting to 1.
admin.firestore().collection('notifications').orderBy("date",'desc').limit(1).delete();
This is the error I get in the functions log.
"TypeError: admin.firestore(...).collection(...).orderBy(...).limit(...).delete is not a function at exports.updateUser.functions.firestore.document.onUpdate (/srv/index.js:219:97) at cloudFunction (/srv/node_modules/firebase-functions/lib/cloud-functions.js:119:23) at /worker/worker.js:825:24 at at process._tickDomainCallback (internal/process/next_tick.js:229:7)"