Mongo Rest

Create

POST /db/:collection/create

Path Parameters

Name
Type
Description

collection*

String

Collection name, lowercase letters and underscores allowed

Request Body

Name
Type
Description

data*

Object

xdata

Object

Body.data format conversion

txn

String

Transaction ID

- Body
  - **InsertedID** `string`
POST /db/x_departments/create HTTP/1.1
Host: api-x.kainonly.com:8443
Content-Type: application/json

{
    "data": {
        "name": "客服组",
        "description": "客服总部门"
    }
}

# Response

HTTP/1.1 201 Created
Alt-Svc: h3=":8443"; ma=2592000,h3-29=":8443"; ma=2592000
Content-Type: application/json; charset=utf-8
Server: hertz

{
    "InsertedID": "651fe5b2199dfb8ca40ec524"
}

BulkCreate

POST /db/:collection/bulk_create

Path Parameters

Name
Type
Description

collection*

String

Collection name, lowercase letters and underscores allowed

Request Body

Name
Type
Description

data*

Object[]

xdata

Object

Body.data.$ format conversion

txn

String

Transaction ID

Size

POST /db/:collection/size

Path Parameters

Name
Type
Description

collection*

String

Collection name, lowercase letters and underscores allowed

Request Body

Name
Type
Description

filter*

Object

xfilter

Object

Body.filter format conversion

Find

POST /db/:collection/find

Path Parameters

Name
Type
Description

collection*

String

Collection name, lowercase letters and underscores allowed

Query Parameters

Name
Type
Description

sort

String[]

Sort rules <field>:<1|-1>

keys

String[]

Projection

Headers

Name
Type
Description

x-pagesize

Number

Paging size, default 100 customize must be between 1~1000

x-page

Number

Paging Index

Request Body

Name
Type
Description

filter*

Object

xfilter

Object

Body.filter format conversion

FindOne

POST /db/:collection/find_one

Path Parameters

Name
Type
Description

collection*

String

Collection name, lowercase letters and underscores allowed

Query Parameters

Name
Type
Description

keys

String[]

Projection

Request Body

Name
Type
Description

filter*

Object

xfilter

Object

Body.filter format conversion

FindById

GET /db/:collection/:id

Path Parameters

Name
Type
Description

collection*

String

Collection name, lowercase letters and underscores allowed

id*

String

ID, must be MongoId

Query Parameters

Name
Type
Description

keys

String[]

Projection

Update

POST /db/:collection/update

Path Parameters

Name
Type
Description

collection*

String

Collection name, lowercase letters and underscores allowed

Request Body

Name
Type
Description

filter*

Object

xfilter

Object

Body.filter format conversion

data*

Object

xdata

Object

Body.data format conversion

txn

String

Transaction ID

UpdateById

PATCH /db/:collection/:id

Path Parameters

Name
Type
Description

collection*

String

Collection name, lowercase letters and underscores allowed

id*

String

ID, must be MongoId

Request Body

Name
Type
Description

data*

Object

xdata

Object

Body.data format conversion

txn

String

Transaction ID

Replace

PUT /db/:collection/:id

Path Parameters

Name
Type
Description

collection*

String

Collection name, lowercase letters and underscores allowed

id*

String

ID, must be MongoId

Request Body

Name
Type
Description

data*

Object

xdata

Object

Body.data format conversion

txn

String

Transaction ID

Delete

DELETE /db/:collection/:id

Path Parameters

Name
Type
Description

collection*

String

Collection name, lowercase letters and underscores allowed

id*

String

ID, must be MongoId

Query Parameters

Name
Type
Description

txn

String

Transaction ID

BulkDelete

POST /db/:collection/bulk_delete

Path Parameters

Name
Type
Description

collection*

String

Collection name, lowercase letters and underscores allowed

Request Body

Name
Type
Description

filter*

Object

xfilter

Object

Body.filter format conversion

txn

String

Transaction ID

Sort

GET /db/:collection/sort

Path Parameters

Name
Type
Description

collection*

String

Collection name, lowercase letters and underscores allowed

Request Body

Name
Type
Description

data*

Object

data.key*

String

Sorting field, for example: sort

data.values*

String[]

Sorted ID array, ID must be MongoId, array index is order

txn

String

Transaction ID

Transaction

POST /db/transaction

Commit

POST /db/commit

Request Body

Name
Type
Description

txn*

String

Transaction ID

Last updated

Was this helpful?