firebase-realtime-database

Firebase: update an integer value

心已入冬 提交于 2021-02-11 14:38:36
问题 So im coding an inventory management app and I'm using a barcode scanner to scan my products. My idea is that every time that a product gets scanned I need to remove one quantity of it on my database. Like this: Scan product-->quantity=quantity-1 And this is my code @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mFirestore = FirebaseFirestore.getInstance(); scannerView = new ZXingScannerView(this); setContentView(scannerView); private void

Firebase Cloud Functions get data on real time database onCreate

不打扰是莪最后的温柔 提交于 2021-02-11 14:31:07
问题 const functions = require('firebase-functions'); const admin = require('firebase-admin'); admin.initializeApp(); exports.sendNotification = functions.database.ref('/messages/diyetisyen/{uname}/{msgid}/message') .onCreate((snapshot, context) => { let message = snapshot.val(); let uname = context.params.uname; let root = snapshot.ref.root; let token = root.child('/users/' + uname + '/token').ref.token; let payload = { data: { custom_notification: JSON.stringify({ body: message + '', title:

How can I remove specific item from List when data in firebase realtime db is removed?

老子叫甜甜 提交于 2021-02-11 14:30:25
问题 When a data in realtime database is removed, I want to remove the data from list as well. I wrote following code, but it does not work. Is there anybody can help me? @Override public void onChildAdded(@NonNull DataSnapshot dataSnapshot, @Nullable String s) { TodoItem todoItem = dataSnapshot.getValue(TodoItem.class); todoItems.add(todoItem); adapter.setTodoItems(todoItems); } @Override public void onChildChanged(@NonNull DataSnapshot dataSnapshot, @Nullable String s) { } @Override public void

How can I remove specific item from List when data in firebase realtime db is removed?

混江龙づ霸主 提交于 2021-02-11 14:28:45
问题 When a data in realtime database is removed, I want to remove the data from list as well. I wrote following code, but it does not work. Is there anybody can help me? @Override public void onChildAdded(@NonNull DataSnapshot dataSnapshot, @Nullable String s) { TodoItem todoItem = dataSnapshot.getValue(TodoItem.class); todoItems.add(todoItem); adapter.setTodoItems(todoItems); } @Override public void onChildChanged(@NonNull DataSnapshot dataSnapshot, @Nullable String s) { } @Override public void

I cannot retrieve nested child from firebase through pojo class object

不打扰是莪最后的温柔 提交于 2021-02-11 14:23:29
问题 This is my database table: I am saving some user information in Firebase through POJO class during installation i.e. name, photo, phone number. Later on in app user can add trusted contact I am adding it creating a nested child in same user table using POJO class. My question is how to get this trustedcontact value from firebase i.e. contactname1, contactnumber1? This is my POJO class: package com.example.fizatanveerkhan.citycops; import java.util.HashMap; public class UserInformation {

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}`);

Firebase, get specfic chid from parent

假如想象 提交于 2021-02-11 13:27:27
问题 I want to match branch value in all child of student nodes with the value I already have and if matched successfully then I want to retrieve 'Student name' value in matched child see blow image 回答1: You're looking for a query in that case. To match the value of branch and then print the value of studentName for all matching child nodes, you'd do: DatabaseReference ref = FirebaseDatabase.getInstance().getReference(".../students"); Query query = ref.orderByChild("branch").equalTo("Electronics

Firebase, get specfic chid from parent

笑着哭i 提交于 2021-02-11 13:27:00
问题 I want to match branch value in all child of student nodes with the value I already have and if matched successfully then I want to retrieve 'Student name' value in matched child see blow image 回答1: You're looking for a query in that case. To match the value of branch and then print the value of studentName for all matching child nodes, you'd do: DatabaseReference ref = FirebaseDatabase.getInstance().getReference(".../students"); Query query = ref.orderByChild("branch").equalTo("Electronics

React-bootstrap-table2 doesn't show data from Firebase

扶醉桌前 提交于 2021-02-11 13:22:21
问题 I've been trying to retrieve data from Firebase Realtime Database and display it in a react-bootstrap-table2, but I've run into some issues when it comes to actually displaying the data. When I run the code no value is printed into the table, however, there is no error in console. If I set the number of displayed values in the table to 25, an error occurs: Uncaught TypeError: Cannot read property 'timestamp' of undefined. However, if I console.log timestamp I first get an empty array and then

How to get Firebase UID knowing email user?

霸气de小男生 提交于 2021-02-11 13:17:35
问题 I am building a Flutter app where the administrator profile can create users to access their company. The code works right, unless the new user was previously created for another company. In this case an error of type ERROR_EMAIL_ALREADY_IN_USE appears from FIREBASE AUTH. What I want to do is simply retrieve the assigned UID from FIREBASE AUTH, which is necessary to assign the user within my database to an additional company. It's my code... _register(LoginBloc bloc, BuildContext context)