beanbagdb 0.8.7 → 0.8.9

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 +14 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "beanbagdb",
3
- "version": "0.8.7",
3
+ "version": "0.8.9",
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
@@ -836,6 +836,20 @@ export class BeanBagDB {
836
836
  editable_meta_schema: async (criteria)=>{
837
837
  let e = sys_sch.editable_metadata_schema
838
838
  return e
839
+ },
840
+ related_doc: async (criteria) =>{
841
+ // criteria can be link or id
842
+ let get_doc = await this.read(criteria)
843
+ if(get_doc.doc){
844
+ let node = get_doc.doc._id
845
+ let data = await this.search({selector:{
846
+ "schema":"system_edge",
847
+ "$or":[ {'data.node1':{"$in":[node]}},{'data.node2':{"$in":[node]}}]
848
+ },fields:["_id","meta","schema"]})
849
+ return data
850
+ }else{
851
+ throw new ValidationError("Doc not found")
852
+ }
839
853
  }
840
854
  }
841
855
  if(!input.type){throw new ValidationError("No type provided. Must be: "+Object.keys(fetch_docs).join(","))}