JSPM

firelordjs

0.5.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2845
  • Score
    100M100P100Q79447F
  • 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!

🚀 All read and write operation are typed, query field path, field value, collection path, document path, everything is typed!

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

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

✨ Api closely resemble firestore api, low learning curve.

🐉 Zero dependency.

⛲️ Out of box typescript support.

Variants:

  1. react native
  2. nodejs

🦙 Usage

This is wrapper for firestore, you can use firebase v8 or v9

work exactly like firelord, except that:

  1. any kind of create operations is not available, you can only create document using set or add
  2. no offset
  3. more parameter 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