-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbot-db-helper.js
More file actions
30 lines (22 loc) · 799 Bytes
/
bot-db-helper.js
File metadata and controls
30 lines (22 loc) · 799 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
//lets require/import the mongodb native drivers.
var firebase = require("firebase");
var CONFIG = require('./bot-config');
//Initialize firebase
firebase.initializeApp(CONFIG.firebase);
module.exports = {
getQuestionsList : function(CONFIG){
var db = firebase.database(),
questions = db.ref();
return questions;
},
saveChat : function (chatData) {
//get new key from firebase
var newPostKey = firebase.database().ref().child('chatData').push().key;
console.log("KEY - ",newPostKey);
console.log("Chat dat to save - ",chatData);
var newChat = {};
newChat['/chatData/' + newPostKey] = chatData; //set data
//update table
firebase.database().ref().update(newChat);
}
};