Ivan Asmer il y a 4 ans
Parent
commit
420d65f428
1 fichiers modifiés avec 14 ajouts et 0 suppressions
  1. 14 0
      index.js

+ 14 - 0
index.js

@@ -3,6 +3,19 @@ const {asynchronize, openPromise } = require('./asynchronize')
 
 const mm = db => {
     class Savable {
+        constructor(obj, ref, empty=false){
+            this._id    = null
+            this._ref   = ref
+            this._class = this.__proto__.constructor.name
+            this._empty = true
+
+            Savable.addClass(this.__proto__.constructor)
+
+            if (obj){
+                this.populate(obj)
+                this._empty = empty
+            }
+        }
 
         backupRelations(){
             this._loadRelations = {};
@@ -329,6 +342,7 @@ const mm = db => {
 
                     return  obj[_class] = {
                         * find(query, cursorCalls={}){
+                            //console.log(query)
                             let cursor = applyCursorCalls(db.collection(_class).find(query), cursorCalls)
                             let cursorGen = asynchronize({s: cursor.stream(), 
                                                           chunkEventName: 'data',