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

typesafe-node-firestore

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

typesafe-node-firestore

[![npm version](https://badge.fury.io/js/typesafe-node-firestore.svg)](https://badge.fury.io/js/typesafe-node-firestore)

  • 1.4.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4
increased by100%
Maintainers
1
Weekly downloads
 
Created
Source

typesafe-node-firestore

npm version

A library of typescript interfaces that extend existing firestore classes, adding type safety and a better autocomplete experience.

This library is for use with @google-cloud/firestore, while the library its based on is intended for the browser-based Javascript Firestore library.

Based on typesafe-firestore.

Installation

npm install typesafe-node-firestore --save-dev

Usage

You most likely want to import TypedCollectionReference and create your collections as shown below.

import * as firestore from "@google-cloud/firestore";
import { TypedCollectionReference } from "typesafe-node-firestore";

interface Author {
  penName: string;
  shortBiography: string;
  posts: string[];
}

// Create a new client
const firestore = new Firestore();

const AuthorCollection = firestore.collection(
  "authors"
) as TypedCollectionReference<Author>;

And then you can use your typesafe collection the same ways you would use the regular firestore library.

// OK
AuthorCollection.add({
  penName: "",
  shortBiography: "",
  posts: []
});

// TS2322: Type 'number' is not assignable to type 'string'.
AuthorCollection.add({
  penName: 11,
  shortBiography: "",
  posts: []
});

// OK
AuthorCollection.where("penName", "<=", "Barfunk");

// TS2345: Argument of type '"realName"' is not assignable to parameter of type '"penName" | "shortBiography" | "posts" | FieldPath'.
AuthorCollection.where("realName", "<=", "Barfunk");

License

typesafe-node-firestore is MIT licensed.

Keywords

FAQs

Package last updated on 07 Apr 2023

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