Socket
Socket
Sign inDemoInstall

easyorm

Package Overview
Dependencies
95
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    easyorm

Easyorm is a promise-based Node.js ORM for Postgres, MySQL, SQLite and Microsoft SQL Server.


Version published
Weekly downloads
1
Maintainers
1
Created
Weekly downloads
 

Readme

Source

Easyorm

Easyorm is a promise-based Node.js ORM for Postgres, MySQL, SQLite and Microsoft SQL Server.

npm install easyorm

The following types of data can be defined in easyorm: STRING, INT, UINT, SHORT, USHORT, LONG, ULONG, ARRAY, OBJECT, LIST, MAP.

Among them, STRING, INT, UINT, SHORT, USHORT, LONG, ULONG, ARRAY are simple types, divided in the main table.

OBJECT is defined as the package type, itself does not participate in the division, but OBJECT elements involved.

The LIST, MAP is treated as a complex type, divided in the sub-table.

It should be noted that the ARRAY, LIST difference, ARRAY elements must be simple type, LIST elements apply to all types.

In addition, "_key" for LIST and MAP must be simple type.

Using the above data types, you can easily define the data structure, like this:

{
	"_type": "OBJECT",
	"_value": {
		"name": {
			"_type": "STRING"
		},
		"age": {
			"_type": "USHORT"
		},
		"school": {
			"_type": "OBJECT",
			"_value": {
				"name": {
					"_type": "STRING"
				},
				"address": {
					"_type": "STRING"
				}
			}
		},
		"courses": {
			"_type": "LIST",
			"_value": {
				"_type": "OBJECT",
				"_value": {
					"name": {
						"_type": "STRING"
					},
					"book": {
						"_type": "STRING"
					},
					"time": {
						"_type": "ARRAY",
						"_value": {
							"_type": "UINT"
						}
					},
					"teacher": {
						"_type": "MAP",
						"_key": {
							"_type": "UINT"
						},
						"_value": {
							"_type": "OBJECT",
							"_value": {
								"name": {
									"_type": "STRING"
								},
								"age": {
									"_type": "UINT"
								}
							}
						}
					}
				}
			}
		}
	}
}

Easyorm's API is also very simple, you can create table like this:

let Model = require('easyorm').Model;
let student = new Model('student', schema, config);
student.createTable(function (err) {

});

insert data like this:

student.insert(id, dataObj, function (err) {

});

query data like this:

student.query(id, function (err) {

});

delete data like this:

student.del(id, function (err) {

});

update data like this:

student.update(id, data, function (err) {

});

config database connector like this:

{
	"client": "mysql",
	"connection": {
		"host"     : "192.168.68.128",
		"user"     : "root",
		"password" : "123456",
		"database" : "test"
	},
	"pool": {
		"min": 0,
		"max": 7
	}
}

Have fun !

Keywords

FAQs

Last updated on 03 May 2017

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc