import sweet from "firestore-sweet"
const db = sweet(firebase.firestore)
(async () => await db.update(
{likes: db.inc(1), hates: db.del},
"users",
"bob",
"comments",
["likes", ">", 10],
["likes", "desc"],
10
))()
const fs = firebase.firestore()
(async () => {
let batch = fs.batch()
(await fs
.collection("users")
.doc("bob")
.collection("comments")
.where("likes", ">", 10)
.orderBy("likes", "desc")
.limit(10)
.get()
).forEach((ss) => {
batch.update(
ss._ref,
{
likes: firebase.firestore.FieldValue.increment(1),
hates: firebase.firestore.FieldValue.delete()
}
)
})
await batch.commit()
})()