zackyang000/node-odata
关于
A library for easily create OData REST API, abide by OData protocol.
开发工具实测星标增长
- 24小时
- 0
- 7天
- 0
- 15天
- 0
- 1个月
- 正在收集历史
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README.md
原文node-odata
Create awesome REST APIs abide by OData Protocol v4. Its purpose is to easier to creating APIs, make you more focus on business logic.
var odata = require('node-odata');
var server = odata('mongodb://localhost/my-app');
server.resource('books', {
title: String,
price: Number
});
server.listen(3000);
Registers the following routes:
GET /books
GET /books(:id)
POST /books
PUT /books(:id)
DELETE /books(:id)
GET /books/$metadata
Use the following OData query:
Example
GET /books?$select=id, title
GET /books?$top=3&$skip=2
GET /books?$orderby=price desc
GET /books?$filter=price gt 10
GET /books/$metadata
GET ...
Further options
The odata constructor takes 3 arguments: odata(<mongoURL>, <dbPrefix>, <options>);
The options object currently only supports one parameter: expressRequestLimit, this will be parsed to the express middelware as the "limit" option, which allows for configuring express to support larger requests. It can be either a number or a string like "50kb", 20mb", etc.
Current State
node-odata is currently at an beta stage, it is stable but not 100% feature complete. node-odata is written by ECMAScript 6 then compiled by babel. It currently have to dependent on MongoDB yet. The current target is to add more features (eg. $metadata) and make to support other database. (eg. MySQL, PostgreSQL).
Installation
npm install node-odata
DOCUMENTATION
Demo
Live demo and try it:
- GET /books?$select=id, title
- GET /books?$top=3&$skip=2
- GET /books?$orderby=price desc
- GET /books?$filter=price gt 10
- GET /books/$metadata
Support Feature
- Full CRUD Support
- $count
- $filter
- Comparison Operators
- eq
- ne
- lt
- le
- gt
- ge
- Logical Operators
- and
- or
- not
- Comparison Operators
- has
- String Functions
- indexof
- contains
- endswith
- startswith
- length
- substring
- tolower
- toupper
- trim
- concat
- Arithmetic Operators
- add
- sub
- mul
- div
- mod
- Date Functions
- year
- month
- day
- hour
- minute
- second
- fractionalseconds
- date
- time
- totaloffsetminutes
- now
- mindatetime
- maxdatetime
- Math Functions
- round
- floor
- ceiling
- Comparison Operators
- $select
- $top
- $skip
- $orderby
- $expand
- $metadata generation
CONTRIBUTING
We always welcome contributions to help make node-odata better. Please feel free to contribute to this project. The package-lock.json file was last created with node version 16.14.2.
LICENSE
node-odata is licensed under the MIT license. See LICENSE for more information.
探索相关项目
加载中…