Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
An expressive ORM with query builder and supports multiple databases.
See API documentation on official website. Or on GitHub Pages.
NodeJS
version higher than 4.0.0.To install Modelar in you project, just type the following command in your shell or CMD:
npm install modelar --save
This module currently supports these databases:
MySQL/MariaDB
see modelar-mysql-adapter.PostgreSQL
see modelar-postgres-adapter.SQLite
see modelar-sqlite-adapter.MicroSoft SQL Server
see modelar-mssql-adapter.OracleDB
see modelar-oracle-adapter.DB2
see modelar-ibmdb-adapter.Not all adapters are installed automatically, only MySQL/MariaDB
(since
3.0.4) are internally included, you must manually install other adapters if
you want to use them.
Modelar is still growing, more features might be introduced in future versions.
const { DB, Model } = require("modelar");
DB.init({
type: "mysql", // Could be 'mysql', 'maria' or 'postgres' by default.
database: "modelar",
host: "127.0.0.1",
port: 3306,
user: "root",
password: "161301"
});
// Add a global event handler to every queries.
DB.on("query", model=>{
console.log(model.toString())
});
// Define a new class that extends the Model.
class Article extends Model {
constructor(data = {}) {
super(data, {
table: "articles",
primary: "id",
fields: [ "id", "title", "content" ],
searchable: [ "title", "content" ]
});
}
}
(async () => {
var db = null;
try {
db = new DB();
// Create a new table `articles`:
var table = new Table("articles");
table.addColumn("id").primary().autoIncrement();
table.addColumn("title", "varchar", 255).notNull();
table.addColumn("content", "varchar", 1024).notNull();
table = await table.use(db).save();
console.log(table);
console.log("");
// Insert an article into the database with 'Article' model:
var article = new Article;
article.title = "A new article in Modelar circumstance.";
article.content = "This is the content of the article.";
article = await article.use(db).save();
console.log(article);
} catch (e) {
console.log(e);
}
if (db)
db.close();
})();
Above gives a very simple example that shows the convenience and expressive functionality that this package carries, you can go into the real depth of it by checking the API documentation.
This package is written in TypeScript and compiled to ES5 standard (since 3.0.4) with some ES2015 features, so it can run in any version of NodeJS that higher than 4.0.0. But this feature relies on the support of the adapter you're using, so check the specification of the adapter carefully.
FAQs
An expressive ORM with query builder and supports multiple databases.
We found that modelar 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.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.