當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript app.firestore函數代碼示例

本文整理匯總了TypeScript中firebase/app.firestore函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript firestore函數的具體用法?TypeScript firestore怎麽用?TypeScript firestore使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了firestore函數的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: atomic

 atomic() {
   const batch = firebase.firestore().batch();
   /// add your operations here
   const itemDoc = firebase.firestore().doc('items/myCoolItem');
   const userDoc = firebase.firestore().doc('users/userId');
   const currentTime = this.timestamp;
   batch.update(itemDoc, { timestamp: currentTime });
   batch.update(userDoc, { timestamp: currentTime });
   /// commit operations
   return batch.commit();
 }
開發者ID:macliems,項目名稱:JixyFront,代碼行數:11,代碼來源:firestore.service.ts

示例2: beforeEachHelper

export function beforeEachHelper(done): void {
  // Create a new Firebase database ref at a random node
  firestore = firebase.firestore();
  collection = firestore.collection(testCollectionName);
  geofirestore = new GeoFirestore(firestore);
  geocollection = new GeoCollectionReference(collection);
  done();
}
開發者ID:geofirestore,項目名稱:geofirestore-js,代碼行數:8,代碼來源:common.ts

示例3: constructor

 constructor() {
     const firebaseConfig = {
         apiKey: "AIzaSyBw73BRk-qWeZm-fp3-Ijf7s0EemdaWuCQ",
         authDomain: "selecquest.firebaseapp.com",
         databaseURL: "https://selecquest.firebaseio.com",
         projectId: "selecquest",
         storageBucket: "selecquest.appspot.com",
         messagingSenderId: "434339253679"
     };
     firebase.initializeApp(firebaseConfig);
     this.db = firebase.firestore()
     this.db.enablePersistence({experimentalTabSynchronization: true});
 }
開發者ID:scunningham777,項目名稱:SelecQuest,代碼行數:13,代碼來源:game-settings-manager.ts

示例4: setPageView

 public setPageView(key): void {
   const documentReference = this.afs.collection<ContentDetail>('postDetail').doc(key);
   firebase.firestore().runTransaction(page => {
       return page.get(documentReference.ref)
           .then(doc => {
               const newValue = doc.data().view + 1;
               page.update(documentReference.ref, {
                   view: newValue
               });
           });
   }).catch(() => {
     console.log('error');
   });
 }
開發者ID:niawjunior,項目名稱:blog,代碼行數:14,代碼來源:page-view.service.ts

示例5: salvaLog

//****************************Datas */
 salvaLog(type,message,reload=false){
    let user = firebase.auth().currentUser;
    let d = new Date();
    firebase.firestore().collection('logs').add({
      type: type,
      message : JSON.stringify(message),
      date: this.getDate(),
      hour: this.getDate('h'),
    }).then(ref => {
      console.log('Adicionado')
      if(reload){
        window.location.reload();
      }
    })
}
開發者ID:aynoei,項目名稱:promon,代碼行數:16,代碼來源:auth.service.ts

示例6: enableProdMode

import { enableProdMode } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';

import { AppModule } from './app/app.module';
import { environment } from './environments/environment';

if (environment.production) {
  enableProdMode();
}

import * as firebase from 'firebase/app';
import 'firebase/auth';
import 'firebase/firestore';

firebase.initializeApp(environment.firebase);
firebase.firestore().settings({ timestampsInSnapshots: true });

platformBrowserDynamic().bootstrapModule(AppModule, { ngZone: 'noop'})
  .catch(err => console.error(err));
開發者ID:janjachacz,項目名稱:fireship.io,代碼行數:19,代碼來源:main.ts

示例7:

import "firebase/firestore";
import { Project } from "../store/projects/reducer";

const config = {
  apiKey: process.env.REACT_APP_API_KEY,
  authDomain: process.env.REACT_APP_AUTH_DOMAIN,
  databaseURL: process.env.REACT_APP_DATABASE_URL,
  projectId: process.env.REACT_APP_PROJECT_ID,
  storageBucket: process.env.REACT_APP_STORAGE_BUCKET,
  messagingSenderId: process.env.REACT_APP_MESSAGING_SENDER_ID
};

app.initializeApp(config);

export const auth: app.auth.Auth = app.auth();
export const firestore: app.firestore.Firestore = app.firestore();

// Required because @firebase/firestore will change
// the behavior for Date objects stored in Firestore.
// Code expecting dates must be updated
// to expect timestamps instead:
// const timestamp = snapshot.get('created_at');
// const date = timestamp.toDate();
const settings = { timestampsInSnapshots: true };
firestore.settings(settings);

// this.auth.onAuthStateChanged(this.onAuthStateChanged);

// onAuthStateChanged = (user: app.User | null) => {
//   this.user = user;
// };
開發者ID:esseb,項目名稱:scheduler,代碼行數:31,代碼來源:firebase.ts

示例8:

import firebase from "firebase/app";
import "firebase/auth";
import "firebase/firestore";

firebase.initializeApp({
  apiKey: "AIzaSyCjBDyhwbXcp9kEIA2pMHLDGxmCM4Sn6Eg",
  authDomain: "canigraduate-43286.firebaseapp.com",
  projectId: "canigraduate-43286"
});

export const firestore = firebase.firestore();
firestore.settings({ timestampsInSnapshots: true });

export const auth = firebase.auth();
開發者ID:kevmo314,項目名稱:canigraduate.uchicago.edu,代碼行數:14,代碼來源:firebase.ts


注:本文中的firebase/app.firestore函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。