How to use the firebase/app.firestore function in firebase

To help you get started, we’ve selected a few firebase examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github NUS-ALSET / achievements / src / services / actions.js View on Github external
.push({
            ...data,
            createdAt: {
              ".sv": "timestamp"
            },
            type: action.type,
            uid: currentUserId,
            version: process.env.REACT_APP_VERSION,
            otherActionData: actionDataToSave
          }).then((snap)=>{
             firebase
              .database()
                .ref("/logged_events/"+snap.key).update(JSON.parse( JSON.stringify(objIndItems)))
          });*/
        
        const firestore_db = firebase.firestore();
        // Added firestore related changes
        firestore_db.collection("/logged_events").add({
          ...data,
          createdAt: firebase.firestore.Timestamp.now().toMillis(),
          type: action.type,
          uid: currentUserId,
          version: process.env.REACT_APP_VERSION,
          otherActionData: actionDataToSave          
        }).then((snap)=>{                   
          firestore_db.collection("/logged_events").doc(snap.id).update(JSON.parse( JSON.stringify(objIndItems)))
       });
       
      } catch (err) {
        console.error(err, action);
      }
    }
github input-output-hk / symphony-2 / src / App.js View on Github external
initFirebase () {
    try {
      firebase.initializeApp(this.config.fireBase)

      firebase.firestore().enablePersistence()
      this.FBStorage = firebase.storage()
      this.FBStorageRef = this.FBStorage.ref()

      this.FBStorageCircuitRef = this.FBStorageRef.child('bitcoin_circuits')
      this.FBStorageAudioRef = this.FBStorageRef.child('bitcoin_block_audio')

      // await firebase.firestore().enablePersistence()
    } catch (error) {
      console.log(error)
    }

    this.firebaseDB = firebase.firestore()

    // this.anonymousSignin()

    // send ready event
github moflo / jpvcdb / src / app / lib / firebaseManager.js View on Github external
firestore() {
        if (!firebase.apps.length) firebase.initializeApp(clientCredentials)

        var db = firebase.firestore()
        db.settings({timestampsInSnapshots: true})  // Using Timestamps

        return db
    }
github zeit / ncc / test / integration / firebase.js View on Github external
const firebase = require('firebase/app')
require('firebase/firestore')

firebase.initializeApp({ projectId: 'noop' })
const store = firebase.firestore()

store
  .collection('users')
  .get()
  .then(
    () => {
      process.exit(0)
    },
    e => {
      /*
      Error: unresolvable extensions: 'extend google.protobuf.MethodOptions' in .google.api
        at Root.resolveAll (/private/var/folders/c3/vytj6_h56b77f_g72smntm3m0000gn/T/node_modules/protobufjs/src/root.js:243:1)
        at Object.loadSync (/private/var/folders/c3/vytj6_h56b77f_g72smntm3m0000gn/T/a707d6b7ee4afe5b484993180e617e2d/index.js:43406:16)
        at loadProtos (/private/var/folders/c3/vytj6_h56b77f_g72smntm3m0000gn/T/a707d6b7ee4afe5b484993180e617e2d/index.js:16778:41)
        at NodePlatform.module.exports.278.NodePlatform.loadConnection (/private/var/folders/c3/vytj6_h56b77f_g72smntm3m0000gn/T/a707d6b7ee4afe5b484993180e617e2d/index.js:16815:22)
        at FirestoreClient.module.exports.278.FirestoreClient.initializeRest (/private/var/folders/c3/vytj6_h56b77f_g72smntm3m0000gn/T/a707d6b7ee4afe5b484993180e617e2d/index.js:28414:14)
github AntlerVC / firetable / www / src / firebase / index.ts View on Github external
import "firebase/firestore";
import "firebase/functions";
import "firebase/storage";

const config = {
  apiKey: process.env.REACT_APP_FIREBASE_PROJECT_KEY,
  authDomain: `${process.env.REACT_APP_FIREBASE_PROJECT_NAME}.firebaseapp.com`,
  databaseURL: `https://${process.env.REACT_APP_FIREBASE_PROJECT_NAME}.firebaseio.com`,
  projectId: process.env.REACT_APP_FIREBASE_PROJECT_NAME,
  storageBucket: `${process.env.REACT_APP_FIREBASE_PROJECT_NAME}.appspot.com`,
};

firebase.initializeApp(config);

export const auth = firebase.auth();
export const db = firebase.firestore();
export const bucket = firebase.storage();
export const functions = firebase.functions();
export const googleProvider = new firebase.auth.GoogleAuthProvider();
github bpetetot / conference-hall / src / firebase / organizations.js View on Github external
export const fetchOrganizationEvents = organizationId =>
  firebase
    .firestore()
    .collection('events')
    .where('organization', '==', organizationId)
    .get()
github samuraikun / firebase-youtube-clone / src / components / VideoUpload.js View on Github external
async saveVideoMetadata(metadata) {
    const user_id = firebase.auth().currentUser.uid;
    const videoRef = firebase.firestore().doc(`users/${user_id}`).collection('videos').doc();
    metadata = Object.assign(metadata, { uid: videoRef.id });

    await videoRef.set(metadata, { merge: true });
  }
github webcore-it / nuxt2-ssr-on-firebase / src / plugins / firebase.js View on Github external
export default () => {
  if (!firebase.apps.length) {
    firebase.initializeApp(process.env.firebaseConfig);
  }

  const firestore = firebase.firestore();
  const settings = {};
  firestore.settings(settings);
}
github camilla-maciel / query-firestore / src / firestore / setup.js View on Github external
const getInstance = (firebaseKeys) => {
  if (loaded) {
    return firestore;
  }
  
  firebase.initializeApp({
    apiKey: process.env.REACT_APP_FIREBASE_API_KEY,
    projectId: process.env.REACT_APP_FIREBASE_PROJECT_ID,
  });

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

  return firestore;
}
github sampl / firefly / src / actions / createPost.js View on Github external
const createPost = values => {

  ReactGA.event({
    category: 'Post',
    action: 'Create post',
  })

  values.slug = slugify(values.title, {lower: true})
  values._likeCount = 0

  return Firebase.firestore()
    .collection('posts')
    .add(prepareDocForCreate(values))
    .then( () => values)
    .catch( error => {
      alert(`Whoops, couldn't create the post: ${error.message}`)
    })
}