google-cloud-firestore

How to abort a Firestore transaction in case of error

孤人 提交于 2020-03-22 09:56:19
问题 I'm using Firestore runTransaction method in a https Cloud function (running Express). What I want is ensure that if any of the read or write fails the other transaction reads or writes won't run or will rollback if needed. Transaction admin.firestore().runTransaction(async (t) => { const { uid, artworkUid, tagLabel } = req.body; if (!tagLabel) { return Promise.reject('Missing parameters: "tagLabel"'); } if (!artworkUid) { return Promise.reject('Missing parameters: "artworkUid"'); } if

how to print Firestore timestamp as formatted date and time in flutter

别说谁变了你拦得住时间么 提交于 2020-03-22 09:14:44
问题 timestamp return aa Timestamp(seconds=1560523991, nanoseconds=286000000) in flutter firestore snapshot I want to print it properly formatted date and time I m using DateTime.now() to store current DateTime in firestore while creating new records and retrieving it using firestore snapshot but it returning format I notable convert to into formatted date time, for formatting I m using lib intl.dart code for saving data d={'amount':amount, 'desc':desc, 'user_id':user_id, 'flie_ref':url.toString()

How to get Documents Id ? Firestore Paginate

被刻印的时光 ゝ 提交于 2020-03-22 08:42:26
问题 I am using Firebase Firestore Database , I am trying to load data using dual query for pagination recyclerver data, using this Stackoverflow ans link My code is for recycerview to load data private void getNewFireData() { final int limit = 3; final int mmcurrentItem; final int totalItem; final int ScrolledItem; mRecyclerView = rootView.findViewById(R.id.rv_post_list); final LinearLayoutManager mManeger=new LinearLayoutManager(getActivity()); mRecyclerView.setLayoutManager(mManeger); final

Return documents in query snapshot as json string firestore

别来无恙 提交于 2020-03-22 06:37:27
问题 I have a query made in node to firestore to get a collection of document. I want to write the collection as a json string to be parsed by an application. My code is as follows: serverRef = db.collection('servers'); getDocs = serverRef.where('online', '==', true).get() .then(querySnapshot => { if (querySnapshot.empty) { res.send("NO SERVERS AVAILABLE"); } else { var docs = querySnapshot.docs; console.log('Document data:', docs); res.end(JSON.stringify({kind: 'freeforge

error NG6002: Appears in the NgModule.imports of AppModule, but could not be resolved to an NgModule class

最后都变了- 提交于 2020-03-21 16:49:34
问题 First time using firestore and I'm getting this error. It seems to be a problem with Ivy, from my research. I don't have a lot of experience modifying tsconfig.app.json, which is the direction I've been pointed to, following other answers. The only thing I was able to modify from the original project was to use Angular Fire 6 instead of 5, which I had done initially to follow a tutorial. Here's package.json: { "name": "language", "version": "0.0.0", "scripts": { "ng": "ng", "start": "ng serve

error NG6002: Appears in the NgModule.imports of AppModule, but could not be resolved to an NgModule class

让人想犯罪 __ 提交于 2020-03-21 16:48:54
问题 First time using firestore and I'm getting this error. It seems to be a problem with Ivy, from my research. I don't have a lot of experience modifying tsconfig.app.json, which is the direction I've been pointed to, following other answers. The only thing I was able to modify from the original project was to use Angular Fire 6 instead of 5, which I had done initially to follow a tutorial. Here's package.json: { "name": "language", "version": "0.0.0", "scripts": { "ng": "ng", "start": "ng serve

Save and Read Integer Firestore Android

眉间皱痕 提交于 2020-03-21 11:41:19
问题 I'm trying to create a simple Stats activity for my Android game. I'm using the new Firestore database. I have been able to save a document to my Firestore database with a total score, recent score, avg score, total games, and high score, but when i try to read the data back from the database it returns a null. public void readFromDB(){ statsDoc.get().addOnSuccessListener(new OnSuccessListener<DocumentSnapshot>() { @Override public void onSuccess(DocumentSnapshot documentSnapshot) { if

TypeError: Object(…) is not a function on index.js

我是研究僧i 提交于 2020-03-21 07:29:11
问题 Hi i get this error when in my browser when i run my code: TypeError: Object(...) is not a function ./src/index.js src/index.js:31 28 | firebaseStateName: 'firebase' 29 | } 30 | const initialState = {}; 31 | const store = createStore(rootReducer,initialState, 32 | compose( 33 | applyMiddleware(thunk.withExtraArgument({ getFirebase, getFirestore })), 34 | reactReduxFirebase(firebase, config), i tryed using thing libary: http://docs.react-redux-firebase.com/history/v3.0.0/docs/integrations

How to sync Flutter TextField with Firestore field?

一世执手 提交于 2020-03-20 06:31:24
问题 I have task document in Firestore, which has todo field, and TextField in the Flutter UI. Please advice how to make the textfield synced with the todo field, i.e. Any time, text in the textfield is changed as user's typing, update the todo field with the just typed value. Any time, the todo field is updated (manually in the Firestore console or by other user), update the textfield with the most recent value. Thanks! 回答1: First of all, supply a TextEditingController to the TextField (take a

How to automatically backup Firestore database daily

本秂侑毒 提交于 2020-03-18 04:15:12
问题 I would like to backup a Firestore database on a daily basis. My data structure is like this: usersCollection uid defaultCurrency: 'USD' name: 'something' dreamsCollection name image I have looked at firestore-export-import and node-firestore-backup to do the backup and export the data to a JSON file. My questions are: If I create a cloud function how do I run the cloud function daily? What is the best way to do the backup? Should I store the data in firebase storage and how to do this?