Count
Get the amount of records in a collection.
Last updated
Was this helpful?
Get the amount of records in a collection.
Last updated
Was this helpful?
When you want to display how many records your collection has without displaying them. You can pass filter and paging parameters to filter records upfront and get the amount of filtered records.
You register employees from when to when s/he wants to travel, in which country, and you can attach documents related to the business trip. You can use our templates or create collections and taxonomies manually by following our instructions.
Prerequisites:
Create Employees collection and other related taxonomies from the template. See instructions here.
Create a collection of "Business Trips." You can do it manually or just copy-paste JSON and UI schemas into CodeMash Dashboard. See instructions here. The schema itself can be found here.
Let's say you have some records inserted in the "Business Trips" collection.
Let's get all the amount of records in the collection.
Let's filter some records by date ranges.
Let's find business trips that will start in 10 days. We store the "From" data field in CodeMash as a date field, which converts at the end as a UNIX timestamp. See more about the Date field.
We can pass the date range as well to find out trips from the last 30 days.
See more examples of how you can leverage filters
And last one example. Let's find all employee business trips that are planned for the future.
We assume that:
We have a country we are interested in - taxonomy term Id. E.g., We can fetch all terms from the taxonomy called countries and find the term Id of France.
We have an employee Id - employee
We have a date from, the Unix time
.NET
With any REST client
GET
POST
Sometimes it's useful to have the capability to get records amount in the collection without calling the find function. You can pass filter and paging parameters to filter records upfront and get the amount of filtered records. https://docs.codemash.io/api/database/collections/count
/{version}/db/{CollectionName}/count
Collection name - unique, lowercased, collection name without whitespace. E.g., if your collection title you have entered in the CodeMash dashboard is "Business Trips" then collection name would be "business-trips".
The CodeMash API version used to fetch data from the API. If not specified, the last version will be used. E.g.: v2
Filter cannot be passed as query string, use POST method instead.
A limit on the number of objects to be returned, between 1 and 100.
The number of records to skip before counting
Accept Header
API key of your cluster. Can be passed in a header as X-CM-Cluster.
ID of your project. Can be passed in a header as X-CM-ProjectId.
Specify culture code when your response from the API should be localised. E.g.: en
Sometimes it's useful to have the capability to get records amount in the collection without calling the find function. You can pass filter and paging parameters to filter records upfront and get the amount of filtered records. https://docs.codemash.io/api/database/collections/count
/{version}/db/{CollectionName}/count
Collection name - unique, lowercased, collection name without whitespace. E.g., if your collection title you have entered in the CodeMash dashboard is "Business Trips" then collection name would be "business-trips".
The CodeMash API version used to fetch data from the API. If not specified, the last version will be used. E.g.: v2
Accept Header
API key of your cluster. Can be passed in a header as X-CM-Cluster.
ID of your project. Can be passed in a header as X-CM-ProjectId.
Specify culture code when your response from the API should be localised. E.g.: en
A query (in JSON format) that specifies which records to count
A limit on the number of objects to be returned, between 1 and 100.
The number of records to skip before counting