Security News
How Threat Actors are Abusing GitHub’s File Upload Feature to Host Malware
GitHub is susceptible to a CDN flaw that allows attackers to host malware on any public repository.
modelar
Advanced tools
Readme
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.
The npm package modelar receives a total of 5 weekly downloads. As such, modelar popularity was classified as not popular.
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.
Security News
GitHub is susceptible to a CDN flaw that allows attackers to host malware on any public repository.
Security News
At Node Congress, Socket CEO Feross Aboukhadijeh uncovers the darker aspects of open source, where applications that rely heavily on third-party dependencies can be exploited in supply chain attacks.
Research
Security News
The Socket Research team found this npm package includes code for collecting sensitive developer information, including your operating system username, Git username, and Git email.