JSPM

firelordjs

0.7.3
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 191
  • Score
    100M100P100Q82389F
  • License MIT

🔥 Write truly scalable firestore code with complete deep typing firestore wrapper, no more typing hell in your firestore code.

Package Exports

  • firelordjs

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (firelordjs) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

firelordjs(BETA, js only)

npm GitHub PRs Welcome

🐤 Write truly scalable firestore code with complete deep typing firestore wrapper, no more typing hell in your firestore code.

💪🏻 handle object, array, array object, object array...and all kinds of type, regardless of the nesting level!

🚀 The wrapper type all read and write operations; query field path, field value, collection path, document path, type everything!

🔥 Automatically convert all value types to corresponding read types, write types and compare types (good at handling timestamp and field values).

✋🏻 Not only does it safeguard your types, but it also stops you from making any incorrect implementation(use the wrapper incorrectly).

💥 Even the seemly un-type-able Firestore Field Value(serverTimestamp, arrayRemove, arrayUnion and increment) is taken care of, EVERYTHING is typed, NO TYPE IS LEFT BEHIND!!

✨ API closely resembles firestore API, low learning curve.

🌈 Strictly one-time setup per document. Once configured, you are ready. No more confusing setup in the future, simplicity at its finest.

🐉 Zero dependencies.

⛲️ Out of box typescript support.

Variants:

  1. react native
  2. nodejs

🦙 Usage

This is a wrapper for react-native-firebase

work exactly like firelord(doc), except that:

  1. any kind of create operations is not available, you can only create a document using set or add
  2. no offset
  3. more parameters for get and onSnapshot

instead of

// from firelord doc
// don't do this
import { firelord, Firelord } from 'firelord'
import { firestore } from 'firebase-admin'

// create wrapper
const wrapper = firelord(firestore)

do

// do this
import { firelord, Firelord } from 'firelordjs'
// firebase 8
import firebase from 'firebase'
import 'firebase/firestore'

// firebase 9
// import firebase from 'firebase/compat/app'
// import 'firebase/compat/firestore'

firebase.initializeApp({
    apiKey: '### FIREBASE API KEY ###',
    authDomain: '### FIREBASE AUTH DOMAIN ###',
    projectId: '### CLOUD FIRESTORE PROJECT ID ###',
})

const firestore = firebase.firestore

// create wrapper
const wrapper = firelord(firestore)

get and onSnapshot

// import user

// options?:{source: 'default' | 'server' | 'cache'}
user.get(options)

// observer: {
// 	next?: (
// 		snapshot: FirelordFirestore.DocumentSnapshot<Read>
// 	) => void
// 	error?: (error: Error) => void
// },
// options?: { includeMetadataChanges: boolean }
user.onSnapshot(observer, options)

no surprise here, everything is similar to firestore api

the rest is exactly the same as firelord