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

fire-entity

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fire-entity

Allows for storing and retrieving documents in a standardized format from Firestore.

  • 0.8.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
6
Maintainers
1
Weekly downloads
 
Created
Source

Fire Entity

Fire Entity is a JavaScript library for storing and retrieving JSON documents from Firebase and caching them locally to reduce quota usage.

Installation

Use npm or yarn to install Fire Entity.

npm i -S fire-entity
yarn add fire-entity

Usage

import {Entity, EntityFireStore} from 'fire-entity';
import {firestore} from 'firebase/app';
import 'firebase/firestore';

const entityStore = new EntityFireStore(firestore(), {setOwner: true});

const entity: Entity = {
  name: 'Entity A',
  type: 'entities',
};
entityStore.insert(entity);

Instantiating an EntityStore, as shown above, is all you need in order to store and retrieve data from Firebase.

Querying entities

import {Entity, EntityFireStore} from 'fire-entity';
import {firestore} from 'firebase/app';
import 'firebase/firestore';

const entityStore = new EntityFireStore(firestore(), {setOwner: true});

// Retrieving all documents from a collection
entityStore.selectAll('collectionPath').then(entities => console.log(entities));

// Retrieving a subset of documents from a collection
entityStore.selectWhere(
  'collectionPath',
  [{prop: 'age', op: '>', val: 20}]
).then(entities => console.log(entities));

Listening for entity changes

import {Entity, EntityFireStore} from 'fire-entity';
import {firestore} from 'firebase/app';
import 'firebase/firestore';

const entityStore = new EntityFireStore(firestore(), {setOwner: true});

// Listening for changes to all documents from a collection
entityStore.listenAll('collectionPath').subscribe(entities => console.log(entities));

// Listening for changes to a subset of documents from a collection
entityStore.listenWhere(
  'collectionPath',
  [{prop: 'age', op: '>', val: 20}]
).subscribe(entities => console.log(entities));

Roadmap

[x] implement Firestore backend
[ ] implement local caching via IndexedDB

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

License

MIT

FAQs

Package last updated on 26 Apr 2020

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