beanbagdb 0.8.9 → 0.8.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.js +18 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "beanbagdb",
3
- "version": "0.8.9",
3
+ "version": "0.8.11",
4
4
  "description": "A JS library to introduce a schema layer to a No-SQL local database",
5
5
  "main": "src/index.js",
6
6
  "module": "src/index.js",
package/src/index.js CHANGED
@@ -845,8 +845,24 @@ export class BeanBagDB {
845
845
  let data = await this.search({selector:{
846
846
  "schema":"system_edge",
847
847
  "$or":[ {'data.node1':{"$in":[node]}},{'data.node2':{"$in":[node]}}]
848
- },fields:["_id","meta","schema"]})
849
- return data
848
+ },fields:["_id","meta","data"]})
849
+
850
+ // console.log(rel_docs)
851
+ if(data.docs.length>0){
852
+ let record_details = []
853
+ data.docs.map(itm=>{record_details.push(itm.data.node1);record_details.push(itm.data.node2)})
854
+ let records = await this.search({selector:{"_id":{"$in":record_details}},fields:["_id","meta"]})
855
+ let details = {}
856
+ records.docs.map(itm=>{details[itm._id] = itm.meta})
857
+ let edges = []
858
+ data.docs.map(itm=>{
859
+ edges.push({node1: itm.data.node1, node2: itm.data.node2, label: itm.data.edge_name, edge_id: itm._id })
860
+ })
861
+ return{edges, details }
862
+ }else{
863
+ return {}
864
+ }
865
+
850
866
  }else{
851
867
  throw new ValidationError("Doc not found")
852
868
  }