xp-repository
TypeScript icon, indicating that this package has built-in type declarations

0.0.6 • Public • Published

Firestore Database Interface

Introduction

This package provides a convenient interface for interacting with Firestore databases in your Node.js applications. It offers functions for common database operations such as inserting, updating, deleting, and querying documents.

Installation

You can install the package via npm or yarn:

npm install xp-repository

or

yarn add xp-repository

Usage

First, import the package in your application:

import makeRepository from "xp-repository";

Then, create a database interface by passing a function to initialize Firestore:

import { Firestore } from "@google-cloud/firestore";
const firestore = new Firestore();
const repository = makeRepository(() => firestore);

Now, you can use the database interface to perform various operations:

// Insert a new document
await db("users").insert({ name: "John Doe", age: 30 });

// Update an existing document
await db("users").update("userId", { age: 31 });

// Retrieve all documents
const allUsers = await db("users").findAll();

// Find documents by a key-value pair
const activeUsers = await db("users").findAllByKeyValue("status", "active");

// Find a document by ID
const user = await db("users").findById("userId");

// Remove a document by ID
await db("users").remove("userId");

Readme

Keywords

Package Sidebar

Install

npm i xp-repository

Weekly Downloads

8

Version

0.0.6

License

ISC

Unpacked Size

18.9 kB

Total Files

6

Last publish

Collaborators

  • einstein23waf