React-native : Firebase how to get all the data [closed] - firebase

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 5 years ago.
Improve this question
Hi guys how can I request all the data form this kind of DB structure?
I tried this but it's not working:
var recentPostsRef = firebase.database().ref('/store');

You are on the right track, but missing the retrieval part where .then() is used with a callback:
var recentPostsRef = firebase.database().ref('/store');
recentPostsRef.once('value').then(snapshot => {
// snapshot.val() is the dictionary with all your keys/values from the '/store' path
this.setState({ stores: snapshot.val() })
})
The firebase.database.Reference documentation has a lot of good examples and explanations that can help.

Related

Google Scheduled Cloud Function running more than once [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 2 days ago.
Improve this question
I have a Google Cloud Function scheduled to run every day at 00:10 AM, but today the function runned 10 times. I'm using the same approach for more than a year and its the first time this happened. Has someone had the same problem today?
Function
Function log
I'm just concerned about the problem.
Edit:
Thanks for all the comments here. I think its a new "bug" or just a new characteristic of pubsub schedule. In my configs its already. My function was created as bellow:
exports.processarIndicadoresDiaMoldtool = functions.runWith({ memory: '4GB', timeoutSeconds: 540 }).pubsub.schedule('10 0 * * *')
.timeZone('America/Sao_Paulo')
My Pub/Sub retry config are set to 0:
Today the same thing happened in another cloud scheduled function =/
My solution so far was to try make my function idempotent. I ve creat a log in my firestore database to verify when the function was already runned.
//this.nome = function's name
//this.dia = last day the function has runned - I saw some solutions with eventId too
async getFuncaoProcessada() {
const docFuncao = await db.collection("Processamentos")
.doc(this.nome).get();
if(docFuncao.exists){
let dadosFuncao = docFuncao.data();
if(dadosFuncao.dia == this.dia){
return true;
}
}
return false;
}
Thanks a lot for the help.

How to solve key issue of API [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
Hi I try to call some data using API but it shows error message of "invalid key". But In the function I didn't figure out where I can input my key. The code is shown below:
sahie_years <- getCensus(
name = "timeseries/healthins/sahie",
vars = c("NAME", "PCTUI_PT"),
region = "state:01",
time = "from 2006 to 2018")
head(sahie_years)
Can anybody have some ideas?
See documentation here for setting up your API key.
You need to sign up for an API key here.
Once you've done that you can either specify your API key by setting an environment variable using Sys.setenv(CENSUS_KEY="YOUR_CENSUS_KEY_GOES_HERE"), or
just set it directly in your getCensus call by adding the argument key = "YOUR_CENSUS_KEY_GOES_HERE".
For API keys in general, it is often easiest to set them in a .Renviron file, which will make them available in each session using Sys.getenv.

Firebase Database Update creating duplicate node [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I have a users object, in that I am trying to update a specific node(status) by using the firebase update(payload) method. But when I try to do that, instead of updating the value in the parent node, it creates a new child node(duplicate node) with the value being updated there.
let firebaseApp = firebase.initializeApp(firebaseConfig);
let uniqueID = "OEHCrSnKFrd87JDivvA0sLMnj8u1"
firebaseApp.database()ref("users/" + uniqueID).update({
status: false
})
Duplicate node image
On .update() you have to specify the path for the key.
try the following:
let firebaseApp = firebase.initializeApp(firebaseConfig);
let uniqueID = "OEHCrSnKFrd87JDivvA0sLMnj8u1"
let updates = {};
updates["/status"] = false;
firebaseApp.database()ref("users/" + uniqueID).update(updates)

Cloud Functions ERROR: cannot convert an array value in an array value [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 4 years ago.
Improve this question
I am trying to pass in the following 2d array of data into a field of a document using Cloud Functions.
[ [ '-LXRXPFgA6sC9Mg0GQMt', 1, 'Sushi premium' ], [ '-LXRSAp3jpB8EUbZU-0c', 1, 'Caramel Glazed Donuts' ] ]
The error I got is:
>Error: 3 INVALID_ARGUMENT: Cannot convert an array value in an array value.
at Object.exports.createStatusError (/user_code/node_modules/firebase-admin/node_modules/grpc/src/common.js:91:15)
at Object.onReceiveStatus (/user_code/node_modules/firebase-admin/node_modules/grpc/src/client_interceptors.js:1204:28)
at InterceptingListener._callNext (/user_code/node_modules/firebase-admin/node_modules/grpc/src/client_interceptors.js:568:42)
at InterceptingListener.onReceiveStatus (/user_code/node_modules/firebase-admin/node_modules/grpc/src/client_interceptors.js:618:8)
at callback (/user_code/node_modules/firebase-admin/node_modules/grpc/src/client_interceptors.js:845:24)
Nested arrays are not supported in Cloud Firestore. You can store arrays of objects, and those objects can have fields that are arrays, but multi-level arrays are not possible.
You would need to change your data to look something more like:
[
{"id": "-LXRXPFgA6sC9Mg0GQMt","number":1,"label":"Sushi premium"},
// ...
]

what wrong with linq query select condition [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
getting error in my linq query code below:
var imgfoldernme=from ct in db.ShopAssignDetails.OrderByDescending(m=>m.Id).Where(c=>c.CompanyId.ToString()==sh.Cid.ToString() && c.BrandId.ToString()==sh.BId.ToString()).ToList();
Try, you didn't write exact error message so there may be more errors than what we see, this:
var imgfoldernme = db.ShopAssignDetails
.OrderByDescending(m=>m.Id)
.Where(c => c.CompanyId.ToString() == sh.Cid.ToString() && c.BrandId.ToString() == sh.BId.ToString())
.ToList();
Problem is you're trying to use both syntax for LINQ queries. You started to write a query expression (from ... in ...) but actually you didn't provide anything else (calls to OrderByDescending and Where will feed from data source). For a query expression you have at least to provide a select statement too.
you are using linq query syntax and lambda expression at once
use this
var imgfoldernme = db.ShopAssignDetails
.OrderByDescending(m=>m.Id)
.Where(c => c.CompanyId.ToString() == sh.Cid.ToString() && c.BrandId.ToString() == sh.BId.ToString())
.ToList();

Resources