Firestore Sweet

Firestore Sweet

  • Tutorial
  • API
  • Github

Firestore SweetFirestore Syntactic Sugar

import sweet from "firestore-sweet"
const db = sweet(firebase.firestore) // sweetened
(async () => await db.update(
  {likes: db.inc(1), hates: db.del},
  "users",
  "bob",
  "comments",
  ["likes", ">", 10],
  ["likes", "desc"],
  10
))()
const fs = firebase.firestore()
// equivalent firestore sdk code
(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()
})()
Getting Started
Source Code
Firestore Sweet
Docs
Getting StartedAPI Reference
Who's Using Firesotre Sweet ?
WARASHIBEALISCHOOLcrypvoVePress
Where to Find Me ?
ALIS BlogGitHubStar
Follow @ocrybit
Copyright © 2020 Tomoya Nagasawa