2.0.0 • Published 1 year ago

keyv-firestore v2.0.0

Weekly downloads
9
License
Apache-2.0
Repository
github
Last release
1 year ago

keyv-firestore

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

Install - Usage - License: Apache-2.0

npm ci standard

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