fix for null
This commit is contained in:
		
							parent
							
								
									8647faa5a9
								
							
						
					
					
						commit
						cb39b6282e
					
				@ -226,7 +226,16 @@ function wrap(db, dir, dbsMap) {
 | 
				
			|||||||
      });
 | 
					      });
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    DB.find = function (obj, params) {
 | 
					    DB.find = function (obj1, params) {
 | 
				
			||||||
 | 
					      //var obj = obj1;
 | 
				
			||||||
 | 
					      var obj = {};
 | 
				
			||||||
 | 
					      if (obj1) {
 | 
				
			||||||
 | 
					        Object.keys(obj1).forEach(function (key) {
 | 
				
			||||||
 | 
					          if (undefined !== obj1[key]) {
 | 
				
			||||||
 | 
					            obj[key] = obj1[key];
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
      var sql = 'SELECT * FROM \'' + tablename + '\' ';
 | 
					      var sql = 'SELECT * FROM \'' + tablename + '\' ';
 | 
				
			||||||
      var keys = obj && Object.keys(obj);
 | 
					      var keys = obj && Object.keys(obj);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -242,13 +251,11 @@ function wrap(db, dir, dbsMap) {
 | 
				
			|||||||
          }
 | 
					          }
 | 
				
			||||||
          else {
 | 
					          else {
 | 
				
			||||||
            // TODO check that key is some type? ignore undefined?
 | 
					            // TODO check that key is some type? ignore undefined?
 | 
				
			||||||
            if (undefined === obj[key]) {
 | 
					 | 
				
			||||||
            sql += db.escape(snakeCase(key)) + " = '" + db.escape(obj[key]) + "'";
 | 
					            sql += db.escape(snakeCase(key)) + " = '" + db.escape(obj[key]) + "'";
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
          }
 | 
					 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      else if (null !== obj || (params && !params.limit)) {
 | 
					      else if (null !== obj1 || (params && !params.limit)) {
 | 
				
			||||||
        return PromiseA.reject(new Error("to find all you must explicitly specify find(null, { limit: <<int>> })"));
 | 
					        return PromiseA.reject(new Error("to find all you must explicitly specify find(null, { limit: <<int>> })"));
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user