- node-data
- standalone-node-odata
- express-node-odata
- koa-node-odata
- egg-node-odata
- node-odata-core
- node-odata-parser
- node-odata-metadata
- node-odata-adapter
import { Resource } from 'node-odata';
const model = {
title: String,
price: Number,
};
function checkUserAuth() {}
function router() {}
function queryable() {}
export default class Book extends Resource {
constructor() {
super('book', model);
}
@queryable({ pageSize: 10, maxTop: 100 })
async onGetList(next) {
const entities = await next();
}
async onGet(next) {
// do something before
const entity = await next();
// dosomething after
}
async onCreate(next) {
const entity = await next();
}
@checkUserAuth
async onRemove(next) {
const entity = await next();
}
@checkUserAuth
async onUpdate(next) {
const entity = await next();
}
@router['/50off']
async halfPriceAction(id, query) {
const entity = await this.findOneById(id);
entity.price /= 2;
await entity.save();
return entity;
}
}