npm.io
0.15.3 • Published 6 months ago

@emage-me/firestorm

Licence
ISC
Version
0.15.3
Deps
3
Size
112 kB
Vulns
0
Weekly
0
Stars
2

FireODM

The best way for build object oriented code backend with Firestore

FireODM is an Typescript ODM for Google Firestore database, it use the activeRecord patern It was only working with firebase-admin for backend

Main features

  • Use Objects
  • Full Typescript
  • In memory mockup for easy testing

Example

Find a document ID
const user = await User.find('42')
Create a new document
const user = new User({ firstName: 'Jack'})
await user.save()
Make a query
await User.query()
  .where('lastName','==','jack')
  .orderBy('age','asc')
  .limit(2)
  .get()
Define a collection
class User extends Collection {
  static collectionName: string = 'user'
  @field('') firstName: string
  @field('') lastName: string
}
Use in memory mockup
// no firebase emulator needed
process.env.FIRESTORM_MOCKED = 'true'

// clear all in memory data
firestorm.data = {}

Keywords