@voidpkg/firestore
TypeScript icon, indicating that this package has built-in type declarations

1.0.5 • Public • Published

@voidpkg/firestore

Do you need my help? Visit our Discord server.

NPM Downloads License

Installation

npm i @voidpkg/firestore --save
# or
yarn add @voidpkg/firestore

Documentation

Click here to view the documentation.


Importing

import { initializeApp } from "firebase/app";
import { Firestore } from "@voidpkg/firestore";

const firebaseConfig = {
    // ...
};

const app = initializeApp(firebaseConfig);
const db = new Firestore(app);

Usage

// db.Schema(name, schema, options?);
const members = db.Schema("voidpkg-test", {
    id: {
        type: "string",
        required: true,
        unique: true
    },
    name: "string",
    age: "number",
    banned: "boolean",
    views: "array"
}, {
    timestamps: true, // default: false (createdAt, updatedAt)
    disableEvents: false // if true, events will not be emitted and on methods will not work throw errors if used (default: false)
});

members.on("load", (data) => {
    console.log("Loaded", data);
});

members.on("warning", (data) => {
    console.log("Warning", data);
});

members.onSnapshot((data) => {
    console.log("Snapshot", data);
});

members.reset("voidpkg-test")
    .then(() => {

        for (let i = 0; i < 10; i++) {
            members.create({
                id: `voidpkg-${i}`,
                name: "Void Development",
                age: 16,
                banned: false,
                views: [`voidpkg-${i + 5}`, `voidpkg-${i + 3}`]
            })
                .then((data) => {
                    members.updateOne({ id: `voidpkg-${i}` }, {
                        $set: {
                            name: "Void"
                        },
                        $inc: {
                            age: 1
                        },
                        $push: {
                            views: `voidpkg-${i + 1}`
                        },
                        $pull: {
                            views: `voidpkg-${i + 5}`
                        }
                    });
                });
        }
    });


Developed with ❤️ by Void Development

Package Sidebar

Install

npm i @voidpkg/firestore

Weekly Downloads

2

Version

1.0.5

License

MIT

Unpacked Size

41.2 kB

Total Files

43

Last publish

Collaborators

  • clqu