Skip to content

Firebase Cloud Firestore backend for Keyv, the simple persistent key-value storage module

License

Notifications You must be signed in to change notification settings

goto-bus-stop/keyv-firestore

Repository files navigation

keyv-firestore

Firebase Cloud Firestore backend for Keyv, the simple persistent key-value storage module

Install - Usage - License: Apache-2.0

npm ci standard

Compatibility

keyv-firestore is tested with Keyv v3, v4, and v5, on Node.js 14 and up.

Install

npm install keyv-firestore

Usage

keyv-firestore uses nested collections for namespaces and keys. A root collection contains keys for each namespace, and each namespace key contains a single collection that holds key/value pairs. The path to a specific key is root-collection/namespace/namespace/key.

var Keyv = require('keyv')
var KeyvFirestore = require('keyv-firestore')

const keyv = new Keyv({
  store: new KeyvFirestore({
    // the project id to use
    projectId: 'my-firebase-project',
    // REQUIRED: the root collection to store things in
    collection: 'firestore-db-collection'
  })
})

You can set the GOOGLE_APPLICATION_CREDENTIALS environment variable to configure credentials, or pass in a JavaScript object in the credentials option.

const keyv = new Keyv({
  store: new KeyvFirestore({
    projectId: 'my-firebase-project',
    collection: 'firestore-db-collection',
    credentials: require('./path/to/google-credentials.json')
  })
})

Tests

To be able to run tests locally, put a .google-credentials.json file in this repository's root directory.

License

Apache-2.0

About

Firebase Cloud Firestore backend for Keyv, the simple persistent key-value storage module

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published