google-cloud-functions

How to fix “too much contention” on onCreate triggered by batch writes

孤街浪徒 提交于 2020-04-30 08:20:07
问题 I have school object with classrooms and students. Students are each family's sub-collection. When creating a school, I write several hundred families in several write batches. In creating each student, I want to do a few things: update a string in the student's family containing student first names students contain a classroom id, and I wish to update the classroom with some data from the student the school keeps separate list of students for easy lookup, and I want to add the students there

Batch writing in firestore, can I write children before parents?

拜拜、爱过 提交于 2020-04-30 06:28:18
问题 My app parses some JSON and creates data like this: School -- has several sub collections... | Classrooms -- about 25 docs | Staff -- about 30 docs | Families -- ~350 docs, each with sub collections... | Parents -- a few docs, usually 2 | Students -- a few docs, usually 1 or 2 In all, there are about 1500 docs which I write in several batch sets using the following code (for creates, it uses only 'set'): // this.batchOps is a large array of: // [ { operation:'set', ref: firestore ref, data: {

Firestore - Cloud Functions - Get uid

。_饼干妹妹 提交于 2020-04-29 08:19:06
问题 I'm trying to get the UID of the user authenticated by firebase web sdk, in the cloud function. The cloud function is triggered by onWrite event of cloud firestore. This function is triggered when the logged in user is creating/updating items to the cafe. The authentication is handled by Firebase Auth . The security rules enable write only for logged in users. So this event could be tied to a user. export const cfun = functions.firestore.document('cafes/{cafeId}/items/{itemId}').onWrite(async

Cloud Functions: Resized images not loading

99封情书 提交于 2020-04-26 06:11:10
问题 I am following a tutorial to resize images via Cloud Functions on upload and am experiencing two major issues which I can't figure out: 1) If a PNG is uploaded, it generates the correctly sized thumbnails, but the preview of them won't load in Firestorage (Loading spinner shows indefinitely). It only shows the image after I click on "Generate new access token" (none of the generated thumbnails have an access token initially). 2) If a JPEG or any other format is uploaded, the MIME type shows

Cloud Functions: Resized images not loading

*爱你&永不变心* 提交于 2020-04-26 06:09:55
问题 I am following a tutorial to resize images via Cloud Functions on upload and am experiencing two major issues which I can't figure out: 1) If a PNG is uploaded, it generates the correctly sized thumbnails, but the preview of them won't load in Firestorage (Loading spinner shows indefinitely). It only shows the image after I click on "Generate new access token" (none of the generated thumbnails have an access token initially). 2) If a JPEG or any other format is uploaded, the MIME type shows

How to write a function that accepts user email and password from client and registers him? (Firestore functions)

自作多情 提交于 2020-04-18 05:49:25
问题 I have this case where I want to register users with email and password, so I want to write a function which accepts those two parameters and creates a new user and returns a message OK or something. This is my code in React-Native: firebase.functions().httpsCallable('registerNewPatient')({ email: 'testestbmf@hotmail.com', password: 'bbbbbb1' }).then((onfulfilled, onrejected) => { if (onfulfilled) { console.log("OK callback function:", onfulfilled); } else { console.log("Error callback

How to write a function that accepts user email and password from client and registers him? (Firestore functions)

可紊 提交于 2020-04-18 05:49:23
问题 I have this case where I want to register users with email and password, so I want to write a function which accepts those two parameters and creates a new user and returns a message OK or something. This is my code in React-Native: firebase.functions().httpsCallable('registerNewPatient')({ email: 'testestbmf@hotmail.com', password: 'bbbbbb1' }).then((onfulfilled, onrejected) => { if (onfulfilled) { console.log("OK callback function:", onfulfilled); } else { console.log("Error callback

Firebase Cloud Function Transaction write on firestore throws await as an error

感情迁移 提交于 2020-04-18 05:47:48
问题 When I try to carry out a transaction on firestore, it throws me an error Unexpected token admin on the below code exports.issueBook = functions.https.onCall(async(data, context) => { if (!(context.auth && context.auth.token.admin)) { throw new functions.https.HttpsError( 'unauthenticated', 'only authenticated Admins can Issue Books' ); } memberData = { name: data.issueData.memberName, no: data.issueData.memberNo, role: data.issueData.memberRole, } transactionData = { books: data.issueData

Serverless VPC Access Connectors - Unable to connect to cross region network resource

给你一囗甜甜゛ 提交于 2020-04-17 22:12:15
问题 I am trying to connect Cloud SQL Server from Cloud Function. My Cloud SQL Server exists in asia-south1 region and that region doesn't have support for deploying Cloud Functions. So, I created and deployed Cloud Function in asia-east2 region and trying to connect to SQL Server using private IP as instructed at this link: https://cloud.google.com/vpc/docs/configure-serverless-vpc-access. All resources are in same VPC and facing Connection Timeout error. I also observed that if both SQL Server

Serverless VPC Access Connectors - Unable to connect to cross region network resource

微笑、不失礼 提交于 2020-04-17 22:11:51
问题 I am trying to connect Cloud SQL Server from Cloud Function. My Cloud SQL Server exists in asia-south1 region and that region doesn't have support for deploying Cloud Functions. So, I created and deployed Cloud Function in asia-east2 region and trying to connect to SQL Server using private IP as instructed at this link: https://cloud.google.com/vpc/docs/configure-serverless-vpc-access. All resources are in same VPC and facing Connection Timeout error. I also observed that if both SQL Server