keyvalue storage using data in the profile

This commit is contained in:
Adolfo Reyna
2021-09-13 18:40:08 -07:00
parent 8797e5e984
commit f92aa70621
2 changed files with 28 additions and 0 deletions

View File

@@ -81,6 +81,24 @@ userDB = (DB) => {
});
}
DB.getData = async (profileid, key) => {
let profile = await DB.getProfile(profileid);
return profile.data[key];
}
DB.setData = async (profileid, key, value) => {
const _id = DB.ObjectID(profileid);
let update = {
$set:{
["data." + key]: value
}
}
return DB.profileCols.updateOne({_id}, update).catch((err)=>{
console.log(err);
return false;
});
}
DB.addNotification = async (profileid, message) => {
const _id = DB.ObjectID(profileid);
let update = {