Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
:penguin: Antarctic-friendly ORM for Node
Photo (c) by Jason Auch
Adelia is meant to be a fast, simple, promise-based ORM for Node, loosely inspired to Martin Fowler's ActiveRecord pattern popularized by Ruby on Rails. Due to the async IO nature of Node and DB clients, the API must be async. Adelia uses Promises to offer a clean, uncluttered API that's easy to compose and reason about.
has
, get
, set
, unset
.save
, delete
.find
, findById
, findAll
, findByQuery
, countAll
.hasOne
, hasMany
, belongsTo
, hasAndBelongsToMany
.create
.Set these environment variables in your script:
DB
one of the supported databases: mysql
(default), or sqlite
(experimental).Set these variables to configure Adelia to use a MySQL database server:
MYSQL_HOST
host of the MySQL database server.MYSQL_PORT
port of the MySQL database server.MYSQL_USER
username to connect to the MySQL database server.MYSQL_PASSWORD
password of the user of the MySQL database server.MYSQL_DB
name of the MySQL database.This assumes you already have a MySQL server to use. For local development, see the Development section below.
Set this variable to configure Adelia to use a SQLite database:
SQLITE_DB
path to the SQLite database file.Adelia has a concise, promise-based API that allows you to perform chained operations to query and fetch model objects, access their properties, persist, and delete them. Here's an example:
const Model = require('adelia').Model;
// Creates a specialized model class
const Penguin = Model.create('penguin');
// Instantiates a penguin
const emperor = new Penguin({
species: 'Emperor'
});
let emperor_id;
// Saves the penguin to DB
emperor.save()
.then(model => model.get('id'))
.then(id => { emperor_id = id; });
// Fetches a model from the DB
Penguin.find(emperor_id)
.then(model => model.get('species'))
.then(name => console.log(`My species is ${name}`));
// => My species is Emperor
MySQL support is currently stable, with some known issues. SQLite support is currently experimental. Tests are failing locally and in TravisCI. If you'd like to use Adelia on SQLite and can contribute fixes and enhancements, please submit a PR!
Thank you for your interest in Adelia! Feel free to open issues or submit a PR. See the Contributing Guidelines for detailed instructions.
Adelia is a Node module. If you are unsure what to do, follow these steps:
For development, it's best to use a local MySQL server. I use MAMP on Mac OS X, but you can also run MySQL server in a Docker container.
npm install
The default test target should be sufficient for most contributors:
npm test
If you want to run tests for MySQL alone, run:
npm run test-mysql
There are also SQLite specific tests:
npm run test-sqlite
Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.
Copyright (c) 2016, Claudio Procida
FAQs
Antarctic-friendly ORM for Node
We found that adelia 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
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.