Security News
PyPI Introduces Digital Attestations to Strengthen Python Package Security
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
CORMO is an ORM framework for Node.js.
Currently supports:
See https://github.com/croquiscom/cormo/wiki/Future-Plans for future plans.
You can see detail guides on http://croquiscom.github.io/cormo/.
import * as cormo from 'cormo';
const connection = new cormo.Connection('mysql', { database: 'test' });
// this will create two tables - users, posts - in the database.
@cormo.Model()
class User extends cormo.BaseModel {
@cormo.Column({ type: String })
name?: string;
@cormo.Column({ type: cormo.types.Integer })
age?: number;
}
@cormo.Model({ connection }) // set connection explictly
class Post extends cormo.BaseModel {
@cormo.Column(String) // `String` is the same as `type: String`
title?: string;
@cormo.Column('string') // you can also use `string` to specify a string type
body?: string;
@cormo.Column(Date)
date?: Date;
@cormo.ObjectColumn({type: Author}) // You can delcare a nested column with `ObjectColumn` type
author: Author;
}
class Auther extends User {
@cormo.Column(Date)
date_joined? Date;
}
const cormo = require('cormo');
const connection = new cormo.Connection('mysql', { database: 'test' });
// this will create two tables - users, posts - in the database.
const User = connection.model('User', {
name: { type: String },
age: { type: cormo.types.Integer }
});
const Post = connection.model('Post', {
title: String, // `String` is the same as `type: String`
body: 'string', // you can also use `string` to specify a string type
date: Date,
});
cormo = require 'cormo'
connection = new cormo.Connection 'mysql', database: 'test'
# this will create two tables - users, posts - in the database.
class User extends cormo.BaseModel
@column 'name', type: String
@column 'age', type: cormo.types.Integer
class Post extends cormo.BaseModel
@column 'title', String # `String` is the same as `type: String`
@column 'body', 'string' # you can also use `string` to specify a string type
@column 'date', Date
const user1 = new User({ name: 'John Doe', age: 27 });
await user1.save();
const user2 = await User.create({ name: 'John Doe', age: 27 });
const user1 = new User({ name: 'John Doe', age: 27 });
await user1.save();
const user2 = await User.create({ name: 'John Doe', age: 27 });
user1 = new User name: 'John Doe', age: 27
await user1.save()
user2 = await User.create name: 'John Doe', age: 27
const user = await User.find(1);
const users = await User.where({name: 'John Doe'});
const users = await User.where({age: 27})
.select(['name'])
.order('name')
.limit(5)
.skip(100);
const users = await User.where({$or: [ { age: { $lt: 20 } }, { age: { $gt: 60 } } ]})
.where({name: { $contains: 'smi' }});
const posts = await Post.where({
title: 'Lorem ipsum',
'author.name': 'John Doe',
});
const user = await User.find(1);
const users = await User.where({name: 'John Doe'});
const users = await User.where({age: 27})
.select(['name'])
.order('name')
.limit(5)
.skip(100);
const users = await User.where({$or: [ { age: { $lt: 20 } }, { age: { $gt: 60 } } ]})
.where({name: { $contains: 'smi' }});
user = await User.find 1
users = await User.where name: 'John Doe'
users = await await User.where(age: 27)
.select(['name'])
.order('name')
.limit(5)
.skip(100)
users = await User.where($or: [ { age: $lt: 20 }, { age: $gt: 60 } ])
.where(name: $contains: 'smi')
const count = await User.count();
const count = await User.count({age: 27});
const count = await User.count();
const count = await User.count({age: 27});
count = await User.count()
count = await User.count age: 27
const user = await User.find(1);
user.age = 30;
await user.save();
const count = await User.find(1).update({age: 10});
const count = await User.where({age: 27}).update({age: 10});
const count = await User.where({age: 35}).update({age: {$inc: 3}});
const posts = await Post.where({title: 'Lorem Ipsum'}).update({ author: {age: {$inc: 5}}});
const user = await User.find(1);
user.age = 30;
await user.save();
const count = await User.find(1).update({age: 10});
const count = await User.where({age: 27}).update({age: 10});
const count = await User.where({age: 35}).update({age: {$inc: 3}});
user = await User.find 1
user.age = 30
await user.save()
count = await User.find(1).update age: 10
count = await User.where(age: 27).update age: 10
count = await User.where(age: 35).update age: $inc: 3
const count = await User.delete({age: 27});
const count = await User.delete({age: 27});
count = await User.delete age: 27
@cormo.Model()
class User extends cormo.BaseModel {
@cormo.Column({ type: String, required: true })
name!: string;
@cormo.Column({ type: Number, required: true })
age!: number;
@cormo.Column({ type: String, unique: true, required: true })
email!: string;
}
const User = connection.model('User', {
name: { type: String, required: true },
age: { type: Number, required: true },
email: { type: String, unique: true, required: true }
});
class User extends cormo.BaseModel
@column 'name', type: String, required: true
@column 'age', type: Number, required: true
@column 'email', type: String, unique: true, required: true
@cormo.Model()
class User extends cormo.BaseModel {
@cormo.Column(String)
name?: string;
@cormo.Column(Number)
age?: number;
@cormo.Column(String)
email?: string;
}
User.addValidator((record) => {
if (record.age<18) {
return 'too young';
}
});
const User = connection.model('User', {
name: String,
age: Number,
email: String
});
User.addValidator((record) => {
if (record.age<18) {
return 'too young';
}
});
class User extends cormo.BaseModel
@column 'name', String
@column 'age', Number
@column 'email', String
@addValidator (record) ->
if record.age < 18
return 'too young'
@cormo.Model()
class User extends cormo.BaseModel {
@cormo.Column(String)
name?: string;
@cormo.Column(Number)
age?: number;
}
User.beforeSave(() => {
this.name = this.name.trim();
});
const User = connection.model('User', {
name: String,
age: Number
});
User.beforeSave(() => {
this.name = this.name.trim();
});
class User extends cormo.BaseModel
@column 'name', String
@column 'age', Number
@beforeSave ->
@name = @name.trim()
@cormo.Model()
class User extends cormo.BaseModel {
@cormo.Column(String)
name?: string;
@cormo.Column(Number)
age?: number;
@cormo.HasMany()
posts?: Post[];
}
@cormo.Model()
class Post extends cormo.BaseModel {
@cormo.Column(String)
title?: string;
@cormo.Column(String)
body?: string;
@cormo.BelongsTo()
user?: User;
}
var User = connection.model('User', {
name: String,
age: Number
});
var Post = connection.model('Post', {
title: String,
body: String
});
User.hasMany(Post);
Post.belongsTo(User);
class User extends cormo.BaseModel
@column 'name', String
@column 'age', Number
@hasMany 'posts'
class Post extends cormo.BaseModel
@column 'title', String
@column 'body', String
@belongsTo 'user'
const records = await Order.where({price: {$lt: 10}})
.group(null, {count: {$sum: 1}, total: {$sum: '$price'}})
.order('total');
const records = await Order.group('customer', {min_price: {$min: '$price'}, max_price: {$max: '$price'}});
const records = await Order.where({price: {$lt: 10}})
.group(null, {count: {$sum: 1}, total: {$sum: '$price'}})
.order('total');
const records = await Order.group('customer', {min_price: {$min: '$price'}, max_price: {$max: '$price'}});
records = await Order.where price: $lt: 10
.group null, count: {$sum: 1}, total: {$sum: '$price'}
.order 'total'
records = await Order.group 'customer', min_price: { $min: '$price' }, max_price: { $max: '$price' }
@cormo.Model()
class Place extends cormo.BaseModel {
@cormo.Column(String)
name?: string;
@cormo.Column(cormo.types.GeoPoint)
location?: [number, number];
}
// create
await Place.create({name: 'Carrier Dome', location: [-76.136131, 43.036240]});
// query
const places = await Place.query().near({location: [-5, 45]}).limit(4);
console.log(places);
const Place = connection.model('Place', {
name: String,
location: cormo.types.GeoPoint
});
// create
await Place.create({name: 'Carrier Dome', location: [-76.136131, 43.036240]});
// query
const places = await Place.query().near({location: [-5, 45]}).limit(4);
console.log(places);
class Place extends cormo.BaseModel
@column 'name', String
@column 'location', cormo.types.GeoPoint
# create
await Place.create name: 'Carrier Dome', location: [-76.136131, 43.036240]
# query
places = await Place.query().near(location: [-5, 45]).limit(4)
console.log places
MIT licenses. See LICENSE for more details.
FAQs
ORM framework for Node.js
The npm package cormo receives a total of 233 weekly downloads. As such, cormo popularity was classified as not popular.
We found that cormo demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.