NoSQL Operations
Insert
Adds one or more rows of data to a database table. Primary keys of the inserted JSON record may be supplied on insert. If a primary key is not provided, then a GUID or incremented number (depending on type) will be generated for each record.
operation
(required) - must always beinsert
database
(optional) - database where the table you are inserting records into lives. The default isdata
table
(required) - table where you want to insert recordsrecords
(required) - array of one or more records for insert
Body
{
"operation": "insert",
"database": "dev",
"table": "dog",
"records": [
{
"id": 8,
"dog_name": "Harper",
"breed_id": 346,
"age": 7
},
{
"id": 9,
"dog_name": "Penny",
"breed_id": 154,
"age": 7
}
]
}
Response: 200
{
"message": "inserted 2 of 2 records",
"inserted_hashes": [8, 9],
"skipped_hashes": []
}
Update
Changes the values of specified attributes in one or more rows in a database table as identified by the primary key. NOTE: Primary key of the updated JSON record(s) MUST be supplied on update.
operation
(required) - must always beupdate
database
(optional) - database of the table you are updating records in. The default isdata
table
(required) - table where you want to update recordsrecords
(required) - array of one or more records for update
Body
{
"operation": "update",
"database": "dev",
"table": "dog",
"records": [
{
"id": 1,
"weight_lbs": 55
},
{
"id": 2,
"owner": "Kyle B",
"weight_lbs": 35
}
]
}
Response: 200
{
"message": "updated 2 of 2 records",
"update_hashes": [1, 3],
"skipped_hashes": []
}
Upsert
Changes the values of specified attributes for rows with matching primary keys that exist in the table. Adds rows to the database table for primary keys that do not exist or are not provided.
operation
(required) - must always beupsert
database
(optional) - database of the table you are updating records in. The default isdata
table
(required) - table where you want to update recordsrecords
(required) - array of one or more records for update
Body
{
"operation": "upsert",
"database": "dev",
"table": "dog",
"records": [
{
"id": 8,
"weight_lbs": 155
},
{
"name": "Bill",
"breed": "Pit Bull",
"id": 10,
"Age": 11,
"weight_lbs": 155
},
{
"name": "Harper",
"breed": "Mutt",
"age": 5,
"weight_lbs": 155
}
]
}
Response: 200
{
"message": "upserted 3 of 3 records",
"upserted_hashes": [8, 10, "ea06fc8e-717b-4c6c-b69d-b29014054ab7"]
}
Delete
Removes one or more rows of data from a specified table.
operation
(required) - must always bedelete
database
(optional) - database where the table you are deleting records lives. The default isdata
table
(required) - table where you want to deleting recordsids
(required) - array of one or more primary key values, which identifies records to delete
Body
{
"operation": "delete",
"database": "dev",
"table": "dog",
"ids": [1, 2]
}
Response: 200
{
"message": "2 of 2 records successfully deleted",
"deleted_hashes": [1, 2],
"skipped_hashes": []
}
Search By ID
Returns data from a table for one or more primary keys.
operation
(required) - must always besearch_by_id
database
(optional) - database where the table you are searching lives. The default isdata
table
(required) - table you wish to searchids
(required) - array of primary keys to retrieveget_attributes
(required) - define which attributes you want returned. Use['*']
to return all attributes
Body
{
"operation": "search_by_id",
"database": "dev",
"table": "dog",
"ids": [1, 2],
"get_attributes": ["dog_name", "breed_id"]
}
Response: 200
[
{
"dog_name": "Penny",
"breed_id": 154
},
{
"dog_name": "Harper",
"breed_id": 346
}
]
Search By Value
Returns data from a table for a matching value.
operation
(required) - must always besearch_by_value
database
(optional) - database where the table you are searching lives. The default isdata
table
(required) - table you wish to searchsearch_attribute
(required) - attribute you wish to search can be any attributesearch_value
(required) - value you wish to search - wild cards are allowedget_attributes
(required) - define which attributes you want returned. Use['*']
to return all attributes
Body
{
"operation": "search_by_value",
"database": "dev",
"table": "dog",
"search_attribute": "owner_name",
"search_value": "Ky*",
"get_attributes": ["id", "dog_name"]
}
Response: 200
[
{
"dog_name": "Penny"
},
{
"dog_name": "Kato"
}
]
Search By Conditions
Returns data from a table for one or more matching conditions. This supports grouping of conditions to indicate order of operations as well.
operation
(required) - must always besearch_by_conditions
database
(optional) - database where the table you are searching lives. The default isdata
table
(required) - table you wish to searchoperator
(optional) - the operator used between each condition -and
,or
. The default isand
offset
(optional) - the number of records that the query results will skip. The default is0
limit
(optional) - the number of records that the query results will include. The default isnull
, resulting in no limitsort
optional - This is an object that indicates the sort order. It has the following properties:attribute
(required) - The attribute to sort bydescending
(optional) - If true, will sort in descending order (defaults to ascending order)next
(optional) - This can define the next sort object that will be used to break ties for sorting when there are multiple records with the same value for the first attribute (follows the same structure assort
).
get_attributes
(required) - define which attributes you want returned. Use['*']
to return all attributesconditions
(required) - the array of conditions objects, specified below, to filter by. Must include one or more object in the array that are a condition or a grouped set of conditions. A condition has the following properties:search_attribute
(required) - the attribute you wish to search, can be any attributesearch_type
(required) - the type of search to perform -equals
,contains
,starts_with
,ends_with
,greater_than
,greater_than_equal
,less_than
,less_than_equal
,between
search_value
(required) - case-sensitive value you wish to search. If thesearch_type
isbetween
then use an array of two values to search between Or a set of grouped conditions has the following properties:operator
(optional) - the operator used between each condition -and
,or
. The default isand
conditions
(required) - the array of conditions objects as described above.
Body
{
"operation": "search_by_conditions",
"database": "dev",
"table": "dog",
"operator": "and",
"offset": 0,
"limit": 10,
"sort": {
"attribute": "id",
"next": {
"attribute": "age",
"descending": true
}
},
"get_attributes": ["*"],
"conditions": [
{
"search_attribute": "age",
"search_type": "between",
"search_value": [5, 8]
},
{
"search_attribute": "weight_lbs",
"search_type": "greater_than",
"search_value": 40
},
{
"operator": "or",
"conditions": [
{
"search_attribute": "adorable",
"search_type": "equals",
"search_value": true
},
{
"search_attribute": "lovable",
"search_type": "equals",
"search_value": true
}
]
}
]
}
Response: 200
[
{
"__createdtime__": 1620227719791,
"__updatedtime__": 1620227719791,
"adorable": true,
"age": 7,
"breed_id": 346,
"dog_name": "Harper",
"id": 2,
"owner_name": "Stephen",
"weight_lbs": 55
},
{
"__createdtime__": 1620227719792,
"__updatedtime__": 1620227719792,
"adorable": true,
"age": 7,
"breed_id": 348,
"dog_name": "Alby",
"id": 3,
"owner_name": "Kaylan",
"weight_lbs": 84
},
{
"__createdtime__": 1620227719792,
"__updatedtime__": 1620227719792,
"adorable": true,
"age": 6,
"breed_id": 347,
"dog_name": "Billy",
"id": 4,
"owner_name": "Zach",
"weight_lbs": 60
},
{
"__createdtime__": 1620227719792,
"__updatedtime__": 1620227719792,
"adorable": true,
"age": 5,
"breed_id": 250,
"dog_name": "Gemma",
"id": 8,
"owner_name": "Stephen",
"weight_lbs": 55
},
{
"__createdtime__": 1620227719792,
"__updatedtime__": 1620227719792,
"adorable": true,
"age": 8,
"breed_id": 104,
"dog_name": "Bode",
"id": 11,
"owner_name": "Margo",
"weight_lbs": 75
}
]