Gathering detailed insights and metrics for redentities
Gathering detailed insights and metrics for redentities
npm install redentities
Typescript
Module System
Node Version
NPM Version
54.8
Supply Chain
92.1
Quality
69.6
Maintenance
25
Vulnerability
94.8
License
JavaScript (100%)
Total Downloads
4,125
Last Day
1
Last Week
12
Last Month
44
Last Year
246
31 Commits
1 Watching
1 Branches
2 Contributors
Latest Version
2.2.4
Package Id
redentities@2.2.4
Unpacked Size
3.98 MB
Size
1.64 MB
File Count
87
NPM Version
8.3.0
Node Version
12.22.1
Cumulative downloads
Total Downloads
Last day
0%
1
Compared to previous day
Last week
-33.3%
12
Compared to previous week
Last month
175%
44
Compared to previous month
Last year
-23.8%
246
Compared to previous year
Red Entities is a simple but flexible and fast object-mapper & sql query builder.
This is a subproject of Mantra Framework you can use freely in your own projects.
Red Entities is focused on minimal typing when accesing data and the definition of database models using schemes (simple json objects).
A model is defined in a json object, called schema.
Data access (inserts, selects, removes and updates), are done by selectors for a fast an simple writing of the sentences.
Tested with:
Thus, has been fully tested with:
1$ npm i redentities --save
Change database configuration providers in file located at:
/test/providersconfig.json
Testing will create many databases and tables.
Then, just run (mocha required):
1$ npm run testmysql 2$ npm run testsqlite 3$ npm run testpostgresql
As a basic introduction, consider this self-explained schema:
1const sampleSchema = { 2 entities: [ 3 { 4 name : "users", 5 fields: [ 6 { name : "mail", type : "string" }, 7 { name : "password", type : "string" }, 8 { name : "created", type : "datetime"} 9 ], 10 indexes: [ ["mail"], ["created"] ] 11 } 12 ] 13}
Load this schema in an Red Entities object with:
1const RedEntities = require("redentities")({ 2 provider: "mysql", 3 host: "localhost", 4 user: "myuser", 5 password: "mypassword" 6});
Create the schema in database with:
1await RedEntities.Entities(sampleSchema).CreateSchema();
From now on, you can use Red Entities powers with fast sentences like this:
1const db = await RedEntities.Entities(sampleSchema);
2
3const newUserId = await db.users.I().V( {
4 mail: "re@redentities.com",
5 password: "12345" ).R();
Retrieve an entity with simple sentences like:
1const userEntity = await db.users.S().SingleById(userId);
You can find some demos at /demos folders.
To run them, just
1node /demos/<demo name.js>
01-inserts-sample : Insert and retrieve basic values 02-insert-and-iterate : Insert a bulk of values and iterates over them 03-insert-and-deleteall : Insert a bulk of values and removed them 04-json-type : Insert a bulk of json objects and retrieve them
RedEntities
has been fully written by Rafael Gómez Blanes
Professional site at Rafablanes.com
Have a look to my books at Rafa G. Blanes books
Licensed under MIT terms.
Copyright (c) 2019-2021:
You can contact us by GitHub, accesing Mantra web site or at support@mantrajs.com.
No vulnerabilities found.
No security vulnerabilities found.