Skip to content

Adapter to convert typed Firestore data into a standard format.

Notifications You must be signed in to change notification settings

samcorcos/firestore-adapter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Firestore Adapter

npm version npm version

When using the Google APIs googleapis to get data from Firestore, the data comes back in a typed format instead of what you would expect to receive. They are typed with these values.

Installation

Add the package with npm:

npm i --save firestore-adapter

Functionality

When using some Google APIs to get data from Firestore, the response data comes back typed and is not compatible with other Firebase APIs. The values returned from the database look like this, for example:

[ 
  { 
    city: { stringValue: 'WASHINGTON' },
    has_subseccd: { booleanValue: true },
    have_extracts: { nullValue: null },
    score: { doubleValue: 523.3892 },
    have_pdfs: { nullValue: null },
    subseccd: { integerValue: '3' },
  },
]

This package converts the data into a format that you'd expect. Namely:

[
  { city: 'WASHINGTON',
    has_subscribed: true 
    ...
  }
]

Usage

Import and pass the raw data to the function.

const { convert } = require('firestore-adapter')

const rawData = [{ city: { stringValue: 'WASHINGTON' } }]

const result = convert(rawData)

console.log(result) // => [{ city: 'WASHINGTON' }]

About

Adapter to convert typed Firestore data into a standard format.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published