firebase

authorization and authentication mechanism in GCP

廉价感情. 提交于 2021-02-11 14:21:54
问题 I want to create a Udemy like video platform where a user can see all videos but can watch videos only that he has purchased. I am making a rest call to get the videos from the storage bucket from an angular application, using Firebase authentication here. In my GET request to storage bucket I am passing the access token that I got from Firebase authn . Does this access token can be used to determine scope of the user to access video in a bucket? Assume if I have given read access for a video

Firestore Cloud Function - Value of external variable not recognized in .then()

心已入冬 提交于 2021-02-11 14:19:30
问题 I am new to Firestore cloud functions, and trying to run a simple function that triggers onWrite() in one collection and based on that, updates value in different one. I am hitting roadblock where value of variable (const array actually), is not recognized inside the ...get().then(snapshot) => {} method. As I understand the outer variable's scope should be inside as well, shouldn't it? What am I doing wrong? Research on this topic led me to concept of Promises, and I tried creating promise

Flutter Firebase How to make Sequential Query

喜欢而已 提交于 2021-02-11 14:13:59
问题 I am developing a forum application. There are two collections related to user information and topic information in my Firebase database. In the forumTopics collection, I keep the data on each forum topic. When I make a Firebase query, I want to get the data of this topic along with the data of the user corresponding to the topicAuthorUID value. For example, I want to extract the name, avatar information from the document of the user whose topicAuthorUID value is XXX in the userData

swift - Retrieving firebase Image into ImageView

牧云@^-^@ 提交于 2021-02-11 14:13:58
问题 Hello everyone I am struggling with retrieving my image from firebase into my Image view. The first thing I do is create a method to retrieve the photo data in an array here is that code: class PhotoService { static func retrievePhotos(completion: @escaping ([Photo]) -> Void) { //get a databas refrence let db = Firestore.firestore() //get data from "photos" collection db.collection("photos").getDocuments { (snapshot, Error) in //check for errors if Error != nil { //error in retrieving photos

how to validate email before enter to the home page flutter

北慕城南 提交于 2021-02-11 14:13:46
问题 i'm trying to validate my email before the user can enter to the home page. the problem is when i fill the email and password user with aaany thing it give the access without any check. here is my code for sign in page and this is the code of sign up screen 回答1: If it is all about validating the email for formatting , then what you can do is shown below. Put it in your email address validator you are submitting the data for Login/Register validator: (value){ Pattern pattern = r'^(([^<>()[\]\\

swift - Retrieving firebase Image into ImageView

穿精又带淫゛_ 提交于 2021-02-11 14:11:45
问题 Hello everyone I am struggling with retrieving my image from firebase into my Image view. The first thing I do is create a method to retrieve the photo data in an array here is that code: class PhotoService { static func retrievePhotos(completion: @escaping ([Photo]) -> Void) { //get a databas refrence let db = Firestore.firestore() //get data from "photos" collection db.collection("photos").getDocuments { (snapshot, Error) in //check for errors if Error != nil { //error in retrieving photos

Will cost only getting the size of a collection of 1000 docs as 1000 read?

寵の児 提交于 2021-02-11 14:02:27
问题 I am confused about Cloud firestore cost. I want to get the size of a collection of 1000 docs, and I am not reading every doc data, so will it cost me as 1000 read or 1 read? db.collection(`users/${user}/followers`) .get().catch(onErr).then(followers=> { console.log('followers length: ', followers.size); }); I have 1000 docs in followers collection, so as you can see I am only reading the length of collection, so how much will cost me ?? 1000 read or 1 read? 回答1: If in the followers

How to manage add and update data in Firebase

喜欢而已 提交于 2021-02-11 14:01:29
问题 I'm using Flutter. I would like to add data at first. If email or uid had been registered, I want to update data01/02 or add data01/02. How can I specify the initial data. _firestore.collection('members').add({ 'uid': loginUser.uid, 'email': loginUser.email, 'data01': { 'name': name, 'img_url': 'https://www.xxx.xxx/xxx.png', 'data02': { 'phone': phone, } } Please give me advice. 回答1: Assuming you set your document name to your loginUser.uid you can use: String rawJson = '{ "email": loginUser

Flutter Firebase Loop over collection in a document [duplicate]

自作多情 提交于 2021-02-11 14:01:10
问题 This question already has an answer here : Using Flutter Firestore plug in, do something for each sub collection in a document (1 answer) Closed last year . I have this path in my Database: /messages/tT2Q16n1FMZoTNZQOejtWuJdCmD2/ZqihbgR7skcytLAe88fQecmxcIc2-tT2Q16n1FMZoTNZQOejtWuJdCmD2/1579626761580 and from here I have to get content . I am trying this: var snapshot = Firestore.instance.collection('messages').document(user.id).snapshots(); but how can I loop over these items and get content

Retrieving (allpost) data from firebase and using uid want to retrieve user information also

折月煮酒 提交于 2021-02-11 13:58:34
问题 I want retrieve all post then with each post there is a uid, using this uid i want to retrieve user information My code is like this but it is not working and state is not changing in then block getAllPost(){ let allPost = firebase.database().ref("all-post"); let postAll = []; allPost.once("value").then(data => { data.forEach(function (childSnapshot) { let childData = childSnapshot.val(); childData.postId = childSnapshot.key; let userInfo = firebase.database().ref(`users/${childData.uid}`);