Auto generated schemaless ARRAY OPERATION API
[Mongo Database Only]
Request Method: PUT
Push Operation
URL
Request Payload:{
"find": {
"customer_id": 1
},
"operations": [
{
"operation": "push",
"path": "ages",
"dataToPush": [
{
"age": 33,
"birth_year": 1989,
"country_id": 1
}
]
}
]
}
Pull Operation
URL
Request Payload:{
"find": {
"customer_id": 1
},
"operations": [
{
"operation": "pull",
"path": "ages",
"queryToRemove": {
"age": 2,
"birth_year": 1989,
"country_id": 1
}
}
]
}
Pop Operation
- It will remove a single record in ascending direction.
URL
Request Payload:{
"find": {
"customer_id": 5
},
"operations": [
{
"operation": "pop",
"path": "ages",
"direction": 1
}
]
}
- It will remove a single record in descending direction.
URL
Request Payload:{
"find": {
"customer_id": 5
},
"operations": [
{
"operation": "pop",
"path": "ages",
"direction": -1
}
]
}
PullAll Operation
URL
Request Payload:{
"find": {
"customer_id": 1
},
"operations": [
{
"operation": "pullAll",
"path": "ages",
"dataToPull": [
{
"age": 2,
"birth_year": 1989,
"country_id": 1
}
]
}
]
}
Push in all objects
URL
Request Payload:{
"find": {},
"operations": [
{
"operation": "push",
"path": "ages",
"dataToPush": [
{
"age": 2,
"birth_year": 1989
}
]
}
]
}
Pull from all objects
URL
Request Payload:{
"find": {},
"operations": [
{
"operation": "pullAll",
"path": "ages",
"dataToPull": [
{
"age": 2,
"birth_year": 1989
}
]
}
]
}
addToSet
URL
Request Payload:{
"find": {},
"operations": [
{
"operation": "addToSet",
"path": "ages",
"dataToPush": {
"age": 2,
"birth_year": 1989
}
}
]
}
set operation
- 'set' operation will update the value to an array. If the value is already present it does nothing to that array.
- If we provide 'upsert:true' it will add 'field:value' if any related key is not found.
- 'arrayFilters' array is used to find the data object in the array.
URL
Request Payload{
"find": {},
"operations": [
{
"operation": "set",
"upsert": true,
"dataToSet": {
"ages.$[item].age": 4566,
"ages.$[item].birth_year": 1999,
"ages.$[item].birth_date": 29
},
"arrayFilters": [
{
"item.birth_year": 1999
}
]
}
]
}
slice
- 'slice' contains numbers.
- If it's zero it will update the array with an empty array.
- If it's negative it will update the array fields to contain only the last given number of elements.
- If it's positive the array update with only the first given number of elements.
URL
Request Payload{
"find": {
"_id": "63e0775abd0e063920533f7c"
},
"operations": [
{
"operation": "push",
"path": "ages",
"dataToPush": [
{
"age": 66,
"birth_year": 1961,
"country_id": ""
}
],
"slice": 2
}
]
}
position
- Give the index number as 'position' and the data will push at that index.
URL
Request Payload{
"find": {
"_id": "63e0775abd0e063920533f7c"
},
"operations": [
{
"operation": "push",
"path": "ages",
"dataToPush": [
{
"age": 66,
"birth_year": 1961,
"country_id": ""
}
],
"position": 2
}
]
}
sort
- To get the sorted response array data use 'sort'.
- It supports only two values 1 and -1.
- Here, 1 will sort data in ascending order and -1 will give response data in descending order.
URL
Request Payload{
"find": {
"_id": "63e0775abd0e063920533f7c"
},
"operations": [
{
"operation": "push",
"path": "ages",
"dataToPush": [
{
"age": 66,
"birth_year": 1961,
"country_id": ""
}
],
"sort": {
"age": 1
}
}
]
}
Push - Pull both operations in a single payload.
URL
Request Payload:{
"find": {},
"operations": [
{
"operation": "push",
"path": "ages",
"dataToPush": {
"age": 2,
"birth_year": 1989
}
},
{
"operation": "pull",
"path": "ages",
"queryToRemove": {
"age": 2,
"birth_year": 1989
}
}
]
}
$and use in operation in a single payload.
URL
Request Payload:{
"find": {
"customer_id": 3
},
"operations": [
{
"operation": "push",
"path": "ages",
"dataToPush": {
"age": 4,
"birth_year": 3112
}
},
{
"operation": "pull",
"path": "ages",
"queryToRemove": {
"$and": [
{
"age": {
"$gte": 3
}
},
{
"birth_year": 7889
}
]
}
}
]
}
$or use in operation in a single payload.
URL
Request Payload:{
"find": {
"customer_id": 2
},
"operations": [
{
"operation": "push",
"path": "ages",
"dataToPush": {
"age": 4,
"birth_year": 3112
}
},
{
"operation": "pull",
"path": "ages",
"queryToRemove": {
"$or": [
{
"age": {
"$gte": 3
}
},
{
"birth_year": 7889
}
]
}
}
]
}
auto convert String into Number datatype in dataToPush
URL
Request Payload:{
"find": {
"customer_id": 1
},
"operations": [
{
"operation": "push",
"path": "ages",
"dataToPush": [
{
"age": "5",
"birth_year": "1990",
"country_id": "2"
}
]
}
]
}
auto convert String into Number datatype in queryToRemove
URL
Request Payload:{
"find": {
"customer_id": 1
},
"operations": [
{
"operation": "pull",
"path": "ages",
"queryToRemove": {
"age": "5",
"birth_year": "1990",
"country_id": "2"
}
}
]
}
auto convert String into Number datatype in dataToPull
URL
Request Payload:{
"find": {
"customer_id": 1
},
"operations": [
{
"operation": "pullAll",
"path": "ages",
"dataToPull": [
{
"age": "2",
"birth_year": "1989"
}
]
}
]
}
auto convert String into Number datatype in addToSet
URL
Request Payload:{
"find": {
"customer_id": 1
},
"operations": [
{
"operation": "addToSet",
"path": "ages",
"dataToPush": {
"age": "2",
"birth_year": "1989"
}
}
]
}
queryToRemove support object,string,number
URL
Request Payload:{
"find": {
"customer_id": 2
},
"operations": [
{
"operation": "pull",
"path": "ages",
"queryToRemove": {
"birth_year": 1991
}
}
]
}
user multiple operation in single payload
URL
Request Payload:{
"find": {
"customer_id": 5
},
"operations": [
{
"operation": "push",
"path": "ages",
"dataToPush": {
"age": 29,
"birth_year": 1991,
"country_id": 5
}
},
{
"operation": "pull",
"path": "ages",
"queryToRemove": {
"age": 30,
"birth_year": 1992,
"country_id": 5
}
}
]
}
auto save/update field if available in a schema, while performing any operation.
URL
Request Payload:{
"find": {
"customer_id": 4
},
"operations": [
{
"operation": "push",
"path": "ages",
"dataToPush": [
{
"age": 55,
"birth_year": 1972,
"country_id": {
"id": 304,
"country_name": "COLOMBO"
}
}
]
}
]
}
auto convert an object into a string.
URL
Request Payload:{
"find": {
"customer_id": 4
},
"operations": [
{
"operation": "push",
"path": "hobbies",
"dataToPush": [
{
"age": 999,
"birth_year": 2500
},
4896,
["data_type"],
true,
45.55
]
}
]
}
Supported headers
Header | Description |
---|---|
x-am-response-case | It will change the response keys text as requested case. noChange | camelCase | capitalCase | constantCase | dotCase | headerCase | noCase | paramCase | pascalCase | pathCase | sentenceCase | snakeCase |
x-am-response-object-type | To get flat response we use this request header. no_action | make_flat |
x-am-meta | To get the meta-data of requested API. false | true |
x-am-secret | Place secret id from API Maker. |
x-am-internationalization |
We can get backend error messages in any user language and directly show them to the user in UI, so the user can take appropriate actions.
Provide saved internationalization name in request header. |
x-am-run-in-sandbox | System will try to run requests in maximum provided sandbox, so if 1 provided every request will run in one sandbox, even if we have multiple sandbox with multiple API Maker instances. |
x-am-content-type-response | We can provide response type in request header. As provided header value we can expect the response type. application/json | text/xml | text/yaml |
x-am-cache-control | To reset the cache of the requested API manually and get fresh data, we can use 'x-am-cache-control' request header. no_action | reset_cache |
x-am-get-encrypted-data | Encrypt response data and get in to the response. no_encryption | get_only_encryption | get_data_and_encryption |
x-am-authorization | Provide token of API user in "x-am-authorization" header which will be generated from API Users inside API Maker. |
x-am-user-authorization | User token should be provided in 'x-am-user-authorization' header which will be generated based on some database user if required. |
x-aws-authorization | Provide AWS Cognito token in request header 'x-aws-authorization', if required. |
x-google-authorization | Provide Google user token in request header 'x-google-authorization', if required. |
x-azure-authorization | Provide Azure active directory token in request header 'x-azure-authorization', if required. |
x-no-compression | If user do not send 'x-no-compression' in request header, and response characters are more than value of "maxCharsResToCache" than the response will be compressed. |
x-am-sandbox-timeout | If any API did not give a response within given time, the sandbox will break and give a proper error message in the response. |
x-am-encrypted-payload | When user sent encrypted payload, user must have to sent "x-am-encrypted-payload:true". |