i created app.js file with restful (i`m new with restful) this is my file:
var express=require('express');
var app=express();
var user=require('./models/User');
var orientationEnum = {"df":1, "dddd":2, "b":3};
var user=new user();
user.nickname="noa";
user.age=18;
user.orientation=orientationEnum.straight;
app.get('/users',function (req,res) {
user.getUser(req,res,1);
});
app.listen(3000);
console.log('server up....');
i created user js file as my model file, file details:
var firebase=require('firebase');
var serviceAccount = require("../wergwergwegwegweg.json");
firebase.initializeApp({
serviceAccount:"./geggewrgwergwergewgerwgewrgewg.json",
databaseURL: "https://gegew23tergw.firebaseio.com"
});
var User=function () {
this.nickname={
type:'string'
,required:true
},
this.age={
type:'number',
required:true
},
this.orientation={
type:'number',
required:true,
enum:[1,2,3]
}
};
module.exports=User;
module.exports.getUser=function (req,res,limit) {
var ref=firebase.database().ref('USERS');
ref.orderByChild("orientation").equalTo(limit).once('value')
.then(function (snap) {
res.json(snap);
});
}
i tried to create getUser function and run it from app file when run get method, how can i pass req and res from user js file? i have seen examples of mongosDB but i`m using firebase
via boaz android
No comments:
Post a Comment