Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

knex-model

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

knex-model - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

27

lib/base.js

@@ -17,14 +17,31 @@ 'use strict';

Base.find = function(query) {
var self = this;
var knex = this._knex(this._tableName);
// default find all
if(typeof query === 'undefined') {
Array.prototype.push.call(arguments, {});
if(query) {
knex = knex.where.apply(knex, arguments);
}
return knex.select().map(function(item) {
return self.new(item);
});
};
Base.first = function(query) {
var self = this;
var knex = this._knex(this._tableName);
return knex.where.apply(knex, arguments).select().map(function(item) {
return self.new(item);
if(query) {
knex = knex.where.apply(knex, arguments);
}
return knex.first().then(function(result) {
return self.new(result);
});
};
Base.where = function() {
var knex = this._knex(this._tableName);
return knex.where.apply(knex, arguments);
};
Base.create = function(params) {

@@ -31,0 +48,0 @@ return this._knex(this._tableName).insert(params);

6

lib/index.js

@@ -7,3 +7,3 @@ 'use strict';

var KenxModel = {
VERSION: '0.0.2',
VERSION: '0.0.3',
define: define

@@ -33,2 +33,4 @@ };

model._name = name;
// save super class prototype

@@ -42,3 +44,3 @@ model.prototype.super = Base.prototype;

momery[name] = model;
momery[model._name] = model;

@@ -45,0 +47,0 @@ return model;

{
"name": "knex-model",
"version": "0.0.2",
"description": "",
"version": "0.0.3",
"description": "Small ORM",
"main": "index.js",

@@ -14,2 +14,6 @@ "scripts": {

},
"keywords": [
"knex",
"model"
],
"author": "Chunpeng Wen",

@@ -16,0 +20,0 @@ "license": "ISC",

# knex-model
......
Small ORM.
It is built atop the [Knex Query Builder](http://knexjs.org/)

@@ -5,0 +6,0 @@ ## Example

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc