Mongo Rest

Create

POST /db/:collection/create

Path Parameters

Request Body

- 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

Request Body

- Body
  - **InsertedIDs** `string[]`
POST /db/x_coupons/bulk_create HTTP/1.1
Host: api-x.kainonly.com:8443
Content-Type: application/json

{
    "data": [
        {
            "name": "体验卡A",
            "pd": "2023-04-12T22:00:00.906Z",
            "valid": [
                "2023-04-12T22:00:00.906Z",
                "2023-04-13T06:30:05.586Z"
            ]
        },
        {
            "name": "体验卡B",
            "pd": "2023-04-13T22:00:00.906Z",
            "valid": [
                "2023-04-13T22:00:00.906Z",
                "2023-04-14T06:30:05.586Z"
            ]
        },
        {
            "name": "体验卡C",
            "pd": "2023-04-15T22:00:00.906Z",
            "valid": [
                "2023-04-15T22:00:00.906Z",
                "2023-04-16T06:30:05.586Z"
            ]
        }
    ],
    "xdata": {
        "pd": "timestamp",
        "valid": "timestamps"
    }
}

# 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

{
    "InsertedIDs": [
        "651fed56199dfb8ca40ec526",
        "651fed56199dfb8ca40ec527",
        "651fed56199dfb8ca40ec528"
    ]
}

Size

POST /db/:collection/size

Path Parameters

Request Body

- Header
  - **x-total** `string(number)` Total
POST /db/x_orders/size HTTP/1.1
Host: api-x.kainonly.com:8443
Content-Type: application/json

# Response

HTTP/1.1 204 No Content
Alt-Svc: h3=":8443"; ma=2592000,h3-29=":8443"; ma=2592000
Server: hertz
X-Total: 5000

Find

POST /db/:collection/find

Path Parameters

Query Parameters

Headers

Request Body

- Header
  - **X-Total** `string(number)` Total
- Body `object[]` Data array
POST /db/x_orders/find HTTP/1.1
Host: api-x.kainonly.com:8443
Content-Type: application/json

{
    "filter": {}
}

# Response

HTTP/1.1 200 OK
Alt-Svc: h3=":8443"; ma=2592000,h3-29=":8443"; ma=2592000
Server: hertz
X-Total: 5000

[ ... { "_id": "...", ... } 100 raw ... ]

FindOne

POST /db/:collection/find_one

Path Parameters

Query Parameters

Request Body

- Body `object`
POST /db/x_orders/find_one HTTP/1.1
Host: api-x.kainonly.com:8443
Content-Type: application/json

{
    "filter": {
        "no": "3528731257638202"
    }
}

# Response

HTTP/1.1 200 OK
Alt-Svc: h3=":8443"; ma=2592000,h3-29=":8443"; ma=2592000
Server: hertz

{"_id":"64bdd1c042a8e3504975f04e","account":"MfaoSxk","address":"Et velit veniam sed eos et.","create_time":"1994-05-02T13:34:34Z","customer":"King Jules Koelpin","description":"Quidem est est officiis velit est. Provident qui vero placeat eaque mollitia.","email":"jRUnefN@YLXvGfp.info","name":"Prof. Finn Wintheiser","no":"3528731257638202","phone":"104-215-9683","price":5956907.02,"update_time":"1994-05-03T13:34:34Z","valid":["2170-06-15T22:39:42.803Z","2265-03-22T21:48:37.854Z"]}

FindById

GET /db/:collection/:id

Path Parameters

Query Parameters

- Body `object`
GET /db/x_orders/64b14c68b26a163ca034ace7 HTTP/1.1
Host: api-x.kainonly.com:8443

# Response

HTTP/1.1 200 OK
Alt-Svc: h3=":8443"; ma=2592000,h3-29=":8443"; ma=2592000
Server: hertz

{"create_time":"2022-03-08T17:12:28.607+08:00","_id":"64b14c68b26a163ca034ace7","no":"CY12008750579FE7390A801K60S7","name":"Fantastic Plastic Towels","price":980.94,"valid":["2021-09-04T00:23:26.91+08:00","2022-06-12T09:28:07.644+08:00"],"address":"3358 Lang Common","update_time":"2022-03-08T17:12:28.607+08:00","description":"Ergonomic executive chair upholstered in bonded black leather and PVC padded seat and back for all-day comfort and support","account":"94213614","customer":"Faye Hermann","email":"Sven20@hotmail.com","phone":"172828438"}

Update

POST /db/:collection/update

Path Parameters

Request Body

- Body
  - **MatchedCount** `number`
  - **ModifiedCount** `number`
  - **UpsertedCount** `number`
  - **UpsertedID** `string`
POST /db/x_departments/update HTTP/1.1
Host: api-x.kainonly.com:8443
Content-Type: application/json

{
    "filter": {
        "_id": {
            "$in": [
                "64b14d216fd369656e4ad62f",
                "64b14eb16fd369656e4ad632"
            ]
        }
    },
    "xfilter": {
        "_id->$in": "oids"
    },
    "data": {
        "$set": {
            "status": true
        }
    }
}

# Response

HTTP/1.1 200 OK
Alt-Svc: h3=":8443"; ma=2592000,h3-29=":8443"; ma=2592000
Server: hertz

{"MatchedCount":2,"ModifiedCount":2,"UpsertedCount":0,"UpsertedID":null}

UpdateById

PATCH /db/:collection/:id

Path Parameters

Request Body

- Body
  - **MatchedCount** `number`
  - **ModifiedCount** `number`
  - **UpsertedCount** `number`
  - **UpsertedID** `string`
PATCH /db/x_users/64b14e776fd369656e4ad631 HTTP/1.1
Host: api-x.kainonly.com:8443
Content-Type: application/json

{
    "data": {
        "$set": {
            "roles": [
                "62890dfd9491cd1f5a0a7082",
                "62a9dfb2e4354d6b89337122"
            ]
        }
    },
    "xdata": {
        "$set->roles": "oids"
    }
}

# Response

HTTP/1.1 200 OK
Alt-Svc: h3=":8443"; ma=2592000,h3-29=":8443"; ma=2592000
Server: hertz

{"MatchedCount":1,"ModifiedCount":1,"UpsertedCount":0,"UpsertedID":null}

Replace

PUT /db/:collection/:id

Path Parameters

Request Body

- Body
  - **MatchedCount** `number`
  - **ModifiedCount** `number`
  - **UpsertedCount** `number`
  - **UpsertedID** `string`
PUT /db/x_users/64b14e776fd369656e4ad631 HTTP/1.1
Host: xapi.kainonly.com:8443
Content-Type: application/json

{
    "data": {
        "username": "weplanx",
        "password": "pass@VAN1234",
        "department": "62db95ec33c11192c28c61a8",
        "roles": [
            "62890dfd9491cd1f5a0a7082"
        ],
        "metadata": {
            "x": {
                "time": "Sat, 23 Jul 2022 08:44:09 GMT"
            }
        }
    },
    "xdata": {
        "password": "password",
        "department": "oid",
        "roles": "oids",
        "metadata->x->time": "date"
    }
}

# Response

HTTP/1.1 200 OK
Alt-Svc: h3=":8443"; ma=2592000,h3-29=":8443"; ma=2592000
Server: hertz

{"MatchedCount":1,"ModifiedCount":1,"UpsertedCount":0,"UpsertedID":null}

Delete

DELETE /db/:collection/:id

Path Parameters

Query Parameters

- Body
  - **DeletedCount**
DELETE /db/x_users/64b14e776fd369656e4ad631 HTTP/1.1
Host: api-x.kainonly.com:8443

# Response

HTTP/1.1 200 OK
Alt-Svc: h3=":8443"; ma=2592000,h3-29=":8443"; ma=2592000
Server: hertz

{"DeletedCount":1}

BulkDelete

POST /db/:collection/bulk_delete

Path Parameters

Request Body

- Body
  - **DeletedCount**
POST /db/x_departments/bulk_delete HTTP/1.1
Host: api-x.kainonly.com:8443
Content-Type: application/json

{
    "filter": {
        "_id": {
            "$in": [
                "64b14d216fd369656e4ad62f",
                "64b14eb16fd369656e4ad632"
            ]
        }
    },
    "xfilter": {
        "_id->$in": "oids"
    }
}

# Response

HTTP/1.1 200 OK
Alt-Svc: h3=":8443"; ma=2592000,h3-29=":8443"; ma=2592000
Server: hertz

{"DeletedCount":2}

Sort

GET /db/:collection/sort

Path Parameters

Request Body

POST /db/x_departments/sort HTTP/1.1
Host: api-x.kainonly.com:8443
Content-Type: application/json

{
    "data": {
        "key": "sort",
        "values": [
            "64b14eb16fd369656e4ad634",
            "64b14eb16fd369656e4ad633"
        ]
    }
}

Transaction

POST /db/transaction

- Body
  - **txn** `string` Txn Transaction ID

Commit

POST /db/commit

Request Body

- Body `any[]`
POST /db/transaction HTTP/1.1
Host: api-x.kainonly.com:8443

# Response

HTTP/1.1 201 Created
Alt-Svc: h3=":8443"; ma=2592000,h3-29=":8443"; ma=2592000
Server: hertz

{"txn": "499feb97-e4ae-4bc8-96e6-78f55e589687"}

Last updated