I'm trying to add some triggered functions to my firebase account but before that i wanted to learn the basics of firebase queries so i wrote a js file and testing it by writing "node index.js" in my command prompt. Learnt a few basic queries from youtube etc and tried to integrate it in my js file however so far no luck at all. All my queries returns null and i didnt understand what part of it i am doing. Could you please have a look.
Thanks in advance.
My database structure
<firebasename>
users
edRIPg8BcZU9YPbubp7HtQo7phl1
sayilar: 2653
status: "ok"
hakan
sayilar: 5000
status: "waiting"
mehmet
sayilar: 7000
status: "ok"
My database rule:
{
"rules": {
"users": {
".read": true,
".write": true
}
}
}
My index.js file:
var firebase = require('firebase');
var config = {
apiKey: "<my-api-key>",
authDomain: "<firebasename>.firebaseio.com",
databaseURL: "https://<firebasename>.firebaseio.com",
};
firebase.initializeApp(config);
ref = firebase.database().ref();
const events = ref.child('users').child('hakan');
const query =events.orderByChild('status').equalTo('ok').limitToFirst(2);
query.on("value", sorunsuz,sorunlu);
function sorunlu(error) {
console.log("Something went wrong.");
console.log(error);
}
function sorunsuz(data) {
var fruits = data.val();
console.log(fruits);
}
The command promt shows
null
FIREBASE WARNING: Using an unspecified index. Your data will be downloaded and filtered on the client. Consider adding ".indexOn": "status" at /users/hakan to your security rules for better performance.