Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bluespark

Package Overview
Dependencies
Maintainers
1
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bluespark

> Firestore library for TypeScript using io-ts

  • 0.0.8
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
increased by50%
Maintainers
1
Weekly downloads
 
Created
Source

BlueSpark

Firestore library for TypeScript using io-ts

Installation

yarn add firebase bluespark

Usage

import * as firebase from 'firebase'
import * as t from 'io-ts'
import { dayjs, blue, DayjsFromFirestoreTimestamp, FieldValue } from 'bluespark'

firebase.initializeApp({
    apiKey: '### FIREBASE API KEY ###',
    authDomain: '### FIREBASE AUTH DOMAIN ###',
    projectId: '### CLOUD FIRESTORE PROJECT ID ###',
})

const db = firebase.firestore()

// Schema
const Post = blue(
    'posts',
    t.type({
        id: t.number,
        date: t.union([DayjsFromFirestoreTimestamp, FieldValue]), // Dayjs or FieldValue
        text: t.string,
        tags: t.array(t.string),
    }),
)

const posts = Post.within(db) // equivalent to `db.collection('posts')`

get

const post = await Post(posts.doc('doc-path')).get()

// from snapshot
const post = await posts
    .doc('doc-path')
    .get()
    .then(Post.ss)

set, setMerge, update

await Post(posts.doc('doc-path')).set({
    id: 17,
    date: dayjs(),
    text: 'text',
    tags: ['a', 'b'],
})

FAQs

Package last updated on 06 May 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc