
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
es-entity
Advanced tools
ORM framework for Node js based on Ecmascript 6 and Typescript.
Nitin Bansal https://github.com/nitinbansal1989
$ npm install es-entity
Create DB context and provide connection configuration.
const es = require("es-entity");
Entity class is the reference to the table in the database. The property in this class are field objects which refers to the columns of the table.
Note: The class members are camel cased from the snake case database columns. Annotation for custom column name will be implemented in future.
class Employee {
constructor() {
this.id = new es.Number();
this.name = new es.String();
this.description = new es.String();
}
}
Context is provided with the connection parameters of the database to connect.
var config = new es.ConnectionConfig();
config.handler = "mysql";
config.hostname = "localhost";
config.name = "mysql";
config.username = "root";
config.password = "application";
config.database = "test";
Context class is created which extends from es.Context. This class works as database context for all your queries. The property in this class as queryable object to the respective classes.
const Employee_1 = require("./Employee");
class EmpContext extends es.Context {
constructor(config, entityPath) {
super(config, entityPath);
this.employees = new es.DBSet(Employee_1.default);
this.init();
}
}
Provide the database config object and mapping folder object to the context object to bind.
const EmpContext_1 = require("./modal/EmpContext");
var context = new EmpContext_1.default(config);
let p = context.employees.where((a) => {
return (a.id.lt(q)).or(a.id.eq(2));
}).list();
p.then((v) => {
for (var i = 0; i < v.length; i++) {
var j = v[i];
console.log("id: " + j.id + ", name: " + j.name + ", desc: " + j.description);
}
});
let p = context.employees.get(1);
p.then((v) => {
console.log("id: " + v.id + ", name: " + v.name + ", desc: " + v.description);
});
v.description.set("test update 2");
let p = context.employees.update(v);
p.then((v) => {
console.log("id: " + v.id + ", name: " + v.name + ", desc: " + v.description);
console.log("updated");
});
let a = context.employees.getEntity();
a.name.set("name 2");
a.description.set("desc insert 2");
let p = context.employees.insert(a);
p.then((v) => {
console.log("id: " + v.id + ", name: " + v.name + ", desc: " + v.description);
console.log("inserted");
});
let p = context.employees.delete(v);
p.then(() => {
console.log("deleted");
});
Note: Currently it is very basic and only supports mysql. Please provide suggestions if any.
FAQs
ORM framework for Node js based on Ecmascript 6 and Typescript.
We found that es-entity 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.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.