All Projects → 1amageek → pring-admin.ts

1amageek / pring-admin.ts

Licence: MIT license
Cloud Firestore model framework for TypeScript - Google

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to pring-admin.ts

firebase-bundle
A Symfony Bundle for the Firebase PHP Admin SDK
Stars: ✭ 112 (+761.54%)
Mutual labels:  firebase-admin, firestore
Firebase Php
Unofficial Firebase Admin SDK for PHP
Stars: ✭ 1,657 (+12646.15%)
Mutual labels:  firebase-admin, firestore
cms30
🙌 #CMS30 | Free 30 CMS templates
Stars: ✭ 23 (+76.92%)
Mutual labels:  firestore
vue-js-3-firebase-firestore
Vue 3 Firebase Tutorial: Build Firestore CRUD Web Application
Stars: ✭ 34 (+161.54%)
Mutual labels:  firestore
godot-android-plugin-firebase
Godot 3.2.2 Android plugin for Firebase
Stars: ✭ 41 (+215.38%)
Mutual labels:  firestore
unishox js
JS Library for Guaranteed compression of Unicode short strings
Stars: ✭ 27 (+107.69%)
Mutual labels:  firestore
full-stack-firebase
This course will introduce you to Firebase and grow your understanding of the platform until you're comfortable deploying an app to production.
Stars: ✭ 100 (+669.23%)
Mutual labels:  firestore
whatsapp-clone-react
Build a WhatsApp Clone with React JS and FireBase.
Stars: ✭ 38 (+192.31%)
Mutual labels:  firestore
firecms
Awesome Firebase/Firestore-based CMS. The missing admin panel for your Firebase project!
Stars: ✭ 686 (+5176.92%)
Mutual labels:  firestore
foundry-cli
Foundry makes the development of Firebase Functions fast by giving you an out-of-the-box working cloud environment for your development with an access to your production data. It's a CLI tool that gives you a continuous REPL-like feedback about your Firebase Functions.
Stars: ✭ 49 (+276.92%)
Mutual labels:  firestore
AngularPos
A real-time, simple web Point of Sale system written with Angular 12, Firebase (Cloud Firestore), Bootstrap 4 and PrimeNg
Stars: ✭ 67 (+415.38%)
Mutual labels:  firestore
flutter-app
Full Feature Todos Flutter Mobile app with fireStore integration.
Stars: ✭ 138 (+961.54%)
Mutual labels:  firestore
vue-blog
Book blog
Stars: ✭ 31 (+138.46%)
Mutual labels:  firestore
orkan
A content management toolkit for building and managing dynamic React applications with ease.
Stars: ✭ 25 (+92.31%)
Mutual labels:  firestore
demo-firebase-js
A simple Web application that demonstrates how the end-to-end encryption works. The application uses firebase as a backend service for authentication and chat messaging, and Virgil E3Kit SDK for end-to-end encryption.
Stars: ✭ 31 (+138.46%)
Mutual labels:  firestore
serverless-rest-api
Building RESTful Web APIs with Firebase Cloud Function, Firestore, Express and TypeScript
Stars: ✭ 103 (+692.31%)
Mutual labels:  firestore
JewelCase
This is the source code for JewelCase, a sample app demonstrating how to use SwiftUI and Firebase together. This slide deck discusses the architecture of the app: https://www.slideshare.net/peterfriese/building-swiftui-apps-with-firebase
Stars: ✭ 42 (+223.08%)
Mutual labels:  firestore
go-firestorm
Simple Go ORM for Google/Firebase Cloud Firestore
Stars: ✭ 39 (+200%)
Mutual labels:  firestore
wordsreminder
React native application to save words in dictionaries.
Stars: ✭ 33 (+153.85%)
Mutual labels:  firestore
react-firebase-context
A basic set of components that help dealing with Firebase services
Stars: ✭ 41 (+215.38%)
Mutual labels:  firestore

Pring Admin

Firebase Cloud Firestore model framework for TypeScript.

Installation

npm add pring-admin

Usage

TypeScript

required

  "devDependencies": {
    "@types/node": "^10.9.2",
    "typescript": "^3.0.3"
  },

tsconfig.json

For Firebase CloudFunctions

{
  "compilerOptions": {
    "lib": ["es2018", "dom"],
    "module": "commonjs",
    "noImplicitReturns": true,
    "outDir": "lib",
    "experimentalDecorators": true,
    "sourceMap": true,
    "target": "es2018"
  },
  "compileOnSave": true,
  "include": [
    "src"
  ],
  "exclude": [
    "node_modules"
  ]
}

For Admin

import * as admin from 'firebase-admin'
import * as Pring from 'pring'

const app = admin.initializeApp()

Pring.initialize(app.firestore())

Scheme

  • Use @property annotation for property declaration.

SubCollection can not be optional. Initialise it as show below:

import * as Pring from "pring"
const property = Pring.property

class Group extends Pring.Base {
    @property name: string
    @property users: NestedCollection<User> = NestedCollection(this)
}

class User extends Pring.Base {
    @property name: string
    @property groups: ReferenceCollection<Group> = ReferenceCollection(this)
}

Manage data

Initialize

// auto generate ID
let user = new User()

// any ID
let user = new User("YOUR_ID")

// any ID, Handle already saved users
let user = new User("YOUR_ID", {})

memo

The developer is responsible for managing the Document being saved. In Pring it is prohibited to save the already saved Document again.

Please use explicitly by the initialization method. new User("YOUR_ID", {}) let user = new User("YOUR_ID")

Save

let user = new User()
user.name = "hoge"
await user.save()

Get

let user: User = await User.get("USER_ID", User)

Update

let user: User = await User.get("USER_ID", User)
user.name = "UPDATE NAME"
await user.update()
let user: User = new User("USER_ID", {})
user.name = "UPDATE NAME"
await user.update()

Delete

let user: User = await User.get("USER_ID", User)
await user.delete()

SubCollection

You can use ReferenceCollection and NestedCollection. The inserted Object is saved simultaneously with the save of the parent.

let user = new User()
let group = new Group()
user.groups.insert(group)
await user.save()

If you insert the parent after it is saved, you need to use await to guarantee the count of SubCollection.

let user = new User()
await user.save()

let group0 = new Group()
let group1 = new Group()
try {
  await user.groups.insert(group0)
  await user.groups.insert(group1)
} catch(error) {
  console.log(error)
}

DataSource

DataSource is a class that controls Collection of Firestore.

export default class Home extends Vue {

  public async addUser() {
    const user: User = new User()
    user.name = "@1amageek"
    await user.save()
  }

  public created() {
    const dataSource = User.query().dataSource(User)
    dataSource.on((snapshot, changes) => {

      switch (changes.type) {
        case "initial": {
          console.log(dataSource.documents)
          break
        }
        case "update": {
          console.log("insert", changes.insertions)
          console.log("change", changes.modifications)
          console.log("delete", changes.deletions)
          break
        }
        case "error": {
          break
        }
      }
    }).listen()
  }
}

Test

https://facebook.github.io/jest/

npm install -g jest 
jest
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].