Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Readme
A Dead-simple ORM for Node
Allows you to use an better-sqlite3 store for your node app with queries precomposed from your types.
Create a type with name and schema, e.g.,
class Cat {
// Without tableName, the table would be named 'Cat'
static get tableName() {
return 'cats';
}
// Describes the table; you can use standard SQLite types here, as well as `primary key`, `unique`, etc.
static get schema() {
return {
name: 'text primary key',
age: 'integer'
}
}
constructor({ name, age }) {
this.name = name;
this.age = parseInt(age, 10);
}
}
Create an ORMie table from the database and type:
const Ormie = require('ormie');
const cats = new Ormie(db, Cat);
If you need a couple different tables of cats, you can do that:
const otherCats = new Ormie(db, {
name: 'otherCats',
schema: Cat.schema
});
Once you have your table, you can start making queries:
// Your table will not exist until you do this.
cats.create();
// Add a cat
cats.insert({ name: 'Nutmeg', age: 4 });
// Find cats matching a description
cats.find({ name: 'Nutmeg' });
> [ Cat { name: 'Nutmeg', age: 4 } ]
// Find just one cat
cats.first({ name: 'Nutmeg' });
> Cat { name: 'Nutmeg', age: 4 }
// Get the age of a named cat
cats.first({ name: 'Nutmeg', _cols: 'age' })
> 4
// Update any cat named 'Nutmeg' with an age of `5`
cats.update({ age: 5 }, { name: 'Nutmeg' });
// Remove some cats
cats.remove({ age: 5 });
// Drop the cats table
cats.drop();
There are some special search parameters:
_cols
: An array or string. If present, your object will not be instantiated; you'll just get data back. If it's a string,
your results will be stripped down to the raw type in the database for that one column.
_sort
: Order your results by a name or array of names, optionally with a direction (e.g., name:desc
)
_limit
: Limit your results to some number.
_offset
: Only valid if _limit
is present; will shift your results by the number specified.
FAQs
Dead-simple ORM for node using better-sqlite3
The npm package ormie receives a total of 0 weekly downloads. As such, ormie popularity was classified as not popular.
We found that ormie 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
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.