当前位置: 首页>>代码示例>>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;未经允许,请勿转载。