Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
redentities
Advanced tools
Readme
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:
$ 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):
$ npm run testmysql
$ npm run testsqlite
$ npm run testpostgresql
As a basic introduction, consider this self-explained schema:
const sampleSchema = {
entities: [
{
name : "users",
fields: [
{ name : "mail", type : "string" },
{ name : "password", type : "string" },
{ name : "created", type : "datetime"}
],
indexes: [ ["mail"], ["created"] ]
}
]
}
Load this schema in an Red Entities object with:
const RedEntities = require("redentities")({
provider: "mysql",
host: "localhost",
user: "myuser",
password: "mypassword"
});
Create the schema in database with:
await RedEntities.Entities(sampleSchema).CreateSchema();
From now on, you can use Red Entities powers with fast sentences like this:
const db = await RedEntities.Entities(sampleSchema);
const newUserId = await db.users.I().V( {
mail: "re@redentities.com",
password: "12345" ).R();
Retrieve an entity with simple sentences like:
const userEntity = await db.users.S().SingleById(userId);
You can find some demos at /demos folders.
To run them, just
node /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.
FAQs
Simple & fast object-mapper & query builder, MySql, Sqlite AWS RDS mysql based databases supported
The npm package redentities receives a total of 1 weekly downloads. As such, redentities popularity was classified as not popular.
We found that redentities 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
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.