Security News
vlt Debuts New JavaScript Package Manager and Serverless Registry at NodeConf EU
vlt introduced its new package manager and a serverless registry this week, innovating in a space where npm has stagnated.
A bare metal ORM for MongoDB
Iridium was designed to alleviate many of the issues often present in modern ORMs, especially those designed for NoSQL datastores like MongoDB. Namely, these include a high level of bloat and an excessive amount of documentation - vastly raising the barrier to entry. On the flip side of the coin, they also tend to abstract core database functionality away from the developer to the extent that they end up jumping through unnecessary hoops just to get the results they're looking for.
Iridium hopes to solve these issues by providing a bare bones ORM targeted at power users, and those looking for an exceptionally low overhead. It provides much of the indispensable functionality found in ORMs without the fluff.
Iridium is available using npm, which means you can install it locally using npm install iridium
or add it to your project's package.json file to have it installed automatically whenever you run npm install
.
We make use of the Semantic Versioning guidelines for our versioning system, as such we highly recommend you stick to a single major version of Iridium when developing an application. This can easily be handled through your package.json file by doing the following.
{
// ...
"dependencies": {
"iridium": "1.x"
}
}
var iridium = require('iridium');
var database = new iridium({
database: 'demo'
});
database.register('User', new iridium.Model('user', {
firstname: String,
lastname: String,
since: Date,
clown: Boolean,
houses: [{
address: String,
colour: /Red|White|Blue|Green|Pink/
}]
}));
database.connect(function(err, db) {
if(err) throw err;
// at this point database == db
db.User.create({
firstname: 'Billy',
lastname: 'Bob',
since: new Date(),
clown: true,
houses: [
{ address: 'The middle of nowhere', colour: 'Red' }
]
}, function(err, user) {
if(err) throw err;
console.log(JSON.stringify(user));
});
});
The Iridium core (that sounds WAY cooler than I intended when I came up with the name) is where you create a database connection and register any models to be used by the database. Registration of models is optional, however it makes accessing them easier.
When using Iridium, you are required to instantiate a core with a settings object which describes the database server you want to connect to. This is done by calling the core's constructor and passing an object similar to the following.
{
host: 'localhost', // Optional
port: 27018, // Optional
username: '', // Optional
password: '', // Optional
database: 'iridium'
}
Once you've got a core, you need to connect it to the database. This is done by calling the core's connect method and giving it a callback function. TODO
TODO
TODO
The preprocessing framework allows Iridium to convert values from a form better suited to your database into a form more suitable for your application in an entirely transparent manner. This is acomplished through the use of a number of preprocessors which run when retrieving an object from the database, their order is reversed when pushing an object to the database.
The transforms framework provides a low-level means to convert from one value type to another by means of up/down conversion functions. The up functions are used to convert the value before it is sent UPstream to the database, while down functions are used to convert the database value into the DOWNstream value used by your application.
var model = new Model(db, 'modelName', modelSchema, {
preprocessors: [new Database.Convert({
property: {
$up: function(value) { return convertedValueForDatabase; },
$down: function(value) { return convertedValueFromDatabase }
}
})]
});
The renames framework allows you to access properties in a manner better suited to your application while keeping the same schema on the database side. This comes in handy when using the _id field for fields such as a user's username.
var model = new Model(db, 'modelName', modelSchema, {
preprocessors: [new Database.Rename({
_id: 'id'
})]
});
Thanks to Tadahiro Ishisaka for his brilliant nodeintellisense library, it has been used as the basis for IntelliSense support within this module.
I'd also like to thank dresende and dxg from the node-orm2 project for getting me introduced to Node and giving me many of the ideas for how a good ORM should be structured. If you're looking for an easy to use and more fully featured ORM with support for SQL and NoSQL databases, I'd seriously suggest giving node-orm2 a try.
Version 2.0.0
<a style="border-radius: 2px; padding: 4px 8px; background: rgb(64, 120, 192); color: #fff;" href="https://github.com/SierraSoftworks/Iridium/releases/tag/v2.0.0">tag: v2.0.0</a>
npm install iridium@2.0.0
FAQs
A custom lightweight ORM for MongoDB designed for power-users
The npm package iridium receives a total of 89 weekly downloads. As such, iridium popularity was classified as not popular.
We found that iridium 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
vlt introduced its new package manager and a serverless registry this week, innovating in a space where npm has stagnated.
Security News
Research
The Socket Research Team uncovered a malicious Python package typosquatting the popular 'fabric' SSH library, silently exfiltrating AWS credentials from unsuspecting developers.
Security News
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.