Registry / database / firestore-sequelize

firestore-sequelize

JSON →
library0.8.0jsnpmunverified

FirestoreSequelize (v0.8.0) provides a Sequelize-like ORM for Google Cloud Firestore, enabling model definitions, queries (findAll, findOne, findOrCreate), subcollections, and sync operations. It wraps firebase-admin and supports TypeScript types. Key differentiators: intuitive API for developers familiar with Sequelize, automatic subcollection mapping, and schema sync. However, it is experimental (v0.x) with limited community adoption and potential breaking changes. Release cadence is irregular; last update was in 2021.

npm install firestore-sequelize
INSTALL
IMPORT
SIG · FIRESTORE-SEQUELIZ
F
firestore-sequelize
databasejavascriptv0.8.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

defineModel
import { defineModel } from 'firestore-sequelize'
const defineModel = require('firestore-sequelize').defineModel
ESM and CJS both supported; named import recommended.
DataTypes
import { DataTypes } from 'firestore-sequelize'
const { DataTypes } = require('firestore-sequelize')
Same as defineModel, available as named export.
sequelize (instance)
import firestoreSequelize from 'firestore-sequelize'; firestoreSequelize.initializeApp(admin)
const firestoreSequelize = require('firestore-sequelize').default
Default export is the main module; no named 'initializeApp' export.

Initializes firebase-admin, defines a User model, creates a record, and queries non-admin users.

const admin = require('firebase-admin'); const serviceAccount = require('./path/to/serviceAccountKey.json'); admin.initializeApp({ credential: admin.credential.cert(serviceAccount), }); const firestoreSequelize = require('firestore-sequelize'); firestoreSequelize.initializeApp(admin); const { defineModel, DataTypes } = require('firestore-sequelize'); const User = defineModel('users', { login: { type: DataTypes.STRING, required: true }, name: '', email: '', admin: { type: DataTypes.BOOLEAN, required: true, default: false }, coins: 0, }); async function main() { const user = await User.create({ login: 'jdoe', name: 'John Doe', email: 'jdoe@example.com', admin: false, coins: 100 }); console.log('Created user:', user.getId()); const users = await User.findAll({ where: { admin: false } }); console.log('Non-admin users:', users.length); } main().catch(console.error);
Debug
Known issues
breakingVersion 0.8.0 may have breaking changes from earlier 0.x releases due to API refinement.
fix
Review the CHANGELOG or migration guide before upgrading.
affects: <0.8.0
deprecatedThe 'sync' method is experimental and may be removed or changed in future releases.
fix
Avoid relying on sync for production; use manual schema management.
affects: >=0.7.0
gotchaModel default values defined as primitives (e.g., '' or 0) are not validated; only objects with 'type'/DataTypes enforce constraints.
fix
Always define fields with explicit type and required when needed: { type: DataTypes.STRING, required: true }.
affects: >=0.1.0
gotchaSubcollections must be defined via the 'subcollections' option in defineModel; otherwise nested collections are not supported.
fix
When defining a model with subcollections, include subcollections: [ChildModel] in the third argument.
affects: >=0.5.0
breakinginitializeApp() expects a firebase-admin instance; passing an uninitialized admin will throw obscure errors.
fix
Ensure admin.initializeApp() is called before firestoreSequelize.initializeApp(admin).
affects: >=0.1.0
Errors
Common errors & fixes
firestoreSequelize.initializeApp is not a function
Incorrect import; default export used as named import.
fix
Use const firestoreSequelize = require('firestore-sequelize'); then firestoreSequelize.initializeApp(admin).
Cannot read property 'doc' of undefined
initializeApp not called or admin not properly initialized with Firestore database.
fix
Call firestoreSequelize.initializeApp(admin) after admin.initializeApp().
TypeError: DataTypes.BOOLEAN is not a constructor
Importing DataTypes incorrectly (e.g., destructured from wrong path).
fix
Use const { DataTypes } = require('firestore-sequelize'); or import { DataTypes } from 'firestore-sequelize'.
Upgrade
Version history
0.8.0latest on npm
Audit
Dependencies
firebase-adminrequiredRequired for Firestore access and initialization
Agent activity
5 hits · last 30 days
node
4
Resources
firestore-sequelize — npm install firestore-sequelize · libregistry