
Security News
Browserslist-rs Gets Major Refactor, Cutting Binary Size by Over 1MB
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
json-schema-entity
Advanced tools
Manage a group of tables with a parent child relation in SQL that will be seen as a document, or entity, like a no SQL database
Manage a group of tables with a parent child relation in SQL that will be seen as a document, or entity, like a no SQL database
$ npm install --save json-schema-entity
var jse = require('json-schema-entity');
var pgCrLayer = require('pg-cr-layer');
var config = {
user: 'me',
password: 'my password',
host: 'localhost',
port: 5432,
pool: {
max: 25,
idleTimeout: 30000
}
};
var db = new PgCrLayer(config)
var invoiceClass = jse('invoice', {
properties: {
id: {
type: 'integer',
autoIncrement: true,
primaryKey: true
},
client: {
type: 'string'
}
}
});
invoiceClass.hasMany('items', {
properties: {
id: {
type: 'integer',
autoIncrement: true,
primaryKey: true
},
name: {
type: 'string'
},
description: {
type: 'string'
},
price: {
type: 'number',
maxLength: 10,
decimals: 2
},
invoiceId: {
type: 'integer',
$ref: 'invoice'
}
}
});
var invoiceInstance;
var invoice = invoiceClass.new(db);
invoice.createTables() // Will create tables invoice and items
.then(function() {
return invoice.syncTables(); // Then the reference in items
})
.then(function() {
invoiceInstance = invoice.createInstance({
client: 'Jessica',
items: [
{
name: 'diamond',
description: 'a beautiful diamond',
price: 9999.99
}
]
});
return invoiceInstance.save();
})
.then(function() {
console.log(JSON.stringify(invoiceInstance, null, ' '));
/* will log
{
"id": 1,
"client": "Jessica",
"items": [
{
"id": 1,
"name": "diamond",
"description": "a beautiful diamond",
"price": 9999.99,
"invoiceId": 1
}
]
}
*/
MIT © Andre Gloria
FAQs
Manage a group of tables with a parent child relation in SQL that will be seen as a document, or entity, like a no SQL database
The npm package json-schema-entity receives a total of 15 weekly downloads. As such, json-schema-entity popularity was classified as not popular.
We found that json-schema-entity demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Research
Security News
Eight new malicious Firefox extensions impersonate games, steal OAuth tokens, hijack sessions, and exploit browser permissions to spy on users.
Security News
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.