
Research
/Security News
Laravel Lang Compromised with RCE Backdoor Across 700+ Versions
Laravel Lang packages were compromised with an RCE backdoor across hundreds of versions, exposing cloud, CI/CD, and developer secrets.
sqlite-orm
Advanced tools
the ORM framework for sqlite
$ npm install --save sqlite-orm
the coffeescript sample code
Mapper = require 'sqlite-orm'
path = require 'path'
Migration = Mapper.Migration
ModelBase = Mapper.ModelBase
Migration.createTable 'ParentModel', (t) ->
t.addColumn 'name', 'TEXT'
Migration.createTable 'ChildModel', (t) ->
t.addColumn 'name', 'TEXT'
t.addReference 'parentModelId', 'ParentModel'
class ChildModel
ModelBase.includeInto this
constructor: (params) -> @initModel params
@initAssos: ->
@belongsTo ParentModel
class ParentModel
ModelBase.includeInto this
constructor: (params) -> @initModel params
@initAssos: ->
@hasOne ChildModel
mapper = new Mapper path.resolve(__dirname, 'test.db')
mapper.sync()
the corresponding javascript code
var Mapper = require('sqlite-orm');
var Migration = Mapper.Migration;
var ModelBase = Mapper.ModelBase;
var path = require('path');
Migration.createTable('ParentModel', function(t) {
t.addColumn('name', 'TEXT');
});
Migration.createTable('ChildModel', function(t) {
t.addColumn('name', 'TEXT');
t.addReference('parentModelId', 'ParentModel');
});
function ParentModel(params) {
this.initModel(params);
}
ModelBase.includeInto(ParentModel);
function ChildModel(params) {
this.initModel(params);
}
ModelBase.includeInto(ChildModel);
ParentModel.initAssos(function() {
ParentModel.hasOne(ChildModel);
});
ChildModel.initAssos(function() {
ChildModel.belongsTo(ParentModel);
});
mapper = new Mapper(path.resolve(__dirname, 'test.db'));
mapper.sync().then(function() {
});
sync function() synchronize the model definition and the database
return: Promise
close function() close the database
return: Promise
Migration Migration get the Migration class
ModelBase ModelBase get the ModelBase class
INTEGER String the INTEGER data type
REAL String the REAL data type
TEXT String the TEXT data type
BLOB String the BLOB data type
createTable: function(tableName, callback) create the database table
tableName: String
callback: function(tableInfo) create the columns in this callback
*tableInfo*: `TableInfo` the class to create the columns and index
clear: function() clear the table definition
addColumn: function(name, type, opts) add the table column
name: String the column name
type: String the column data type, such as INTEGER or TEXT
opts: Object the column options
addIndex: function(names...) add index for the specific column
names: Array the column names that need index
addReference: function(name, tableName, opts) add foreign key
name: the column name that need index
tableName: the name of table that the index will point to
opts: Object the index options
initAssos: function() declare the association
all the subclass must implement this interface to declare the association
@hasOne: function(ChildModel, opts) declare this Model has one child Model
ChildModel: ModelBase the child Model class
opts: Object the options used for hasOne association
*as*: `String`(optional) the property name to refer to the ChildModel instance,
the default value is "#{childModel}". e.g. ChildModel is 'ChildModel', then the as
value is `childModel`
@hasMany: function(ChildModel, opts) declare this Model has many children.
ChildModel: ModelBase the child Model class
opts: Object the options used for hasOne association
as: String(optional) the property name to refer to the ChildModel instances,
the default value is "#{childModels}". e.g. ChildModel is 'ChildModel', then the as
value is childModels
@belongsTo: function(ParentModel, opts) declare this Model is member of ParentModel
ParentModel: ModelBase the parent Model class
opts: Object the options used for hasOne association
*through*: `String`(optional) the column name that used for foreign key,
the default value is "#{ParentModel}#{primaryKey}". e.g. ParentModel name is 'ParentModel',
primaryKey is 'id', then the foreign key is `parentModelId`.
*as*: `String`(optional) the property name to refer to the ParentModel instance,
the default value is "#{ParentModel}". e.g. ParentModel is 'ParentModel', then the as
value is `parentModel`
@new: function(obj) create a new model object, not saved into database
obj: Object the attributes list
@create: function(obj) just like @new, but save into database
@drop: function() drop the table
@find: function(where, opts) find the object that match the where statement
@findAll: function(where, opts) find all of object match the condition
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using gulp.
Copyright (c) 2015 liuxiong. Licensed under the MIT license.
FAQs
the ORM framework for sqlite
The npm package sqlite-orm receives a total of 1 weekly downloads. As such, sqlite-orm popularity was classified as not popular.
We found that sqlite-orm demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Research
/Security News
Laravel Lang packages were compromised with an RCE backdoor across hundreds of versions, exposing cloud, CI/CD, and developer secrets.

Security News
Socket found a malicious postinstall hook across 700+ GitHub repos, including PHP packages on Packagist and Node.js project repositories.

Security News
Vibe coding at scale is reshaping how packages are created, contributed, and selected across the software supply chain