This commit is contained in:
Cedric Hoelzl 2020-07-01 11:21:12 +02:00
parent 36d98298b1
commit 85d91de996

10
db.js
View File

@ -20,14 +20,14 @@ module.exports = function(name){
this.name = name;
this.db = dbc(name);
this.get_chat = function(obj){
this.get_chat = function(cid){
return new Promise((resolve, reject)=>{
let res = this.db.get("chats").find({ id: obj.chat_id }).value();
let res = this.db.get("chats").find({id:cid}).value();
if(res) return resolve(res);
this.db.get("chats").push({ id:obj.chat_id, lang: 0, geo:{lon:0,lat:0}}).write();
res = this.db.get("chats").find({ id: obj.chat_id }).value();
this.db.get("chats").push({id:cid, tracking:[]}).write();
res = this.db.get("chats").find({id:cid}).value();
if(res) return resolve(res);
return reject({error:true, msg:"Error With DB..."});
@ -48,7 +48,7 @@ module.exports = function(name){
this.get_v = function(cid){
return new Promise((resolve, reject)=>{
resolve(this.db.find({id:cid}).get('tracking').value());
resolve(this.db.find({id:cid}).value().tracking);
});
}