keyv-firestore
TypeScript icon, indicating that this package has built-in type declarations

2.0.0 • Public • Published

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

Package Sidebar

Install

npm i keyv-firestore

Weekly Downloads

30

Version

2.0.0

License

Apache-2.0

Unpacked Size

9.11 kB

Total Files

10

Last publish

Collaborators

  • goto-bus-stop