Finds database records. You can pass projection to return record fields you care about. Also, you can include referenced collections to have all that information in one place.
Ensure that your Project Id and API Key are correct
Ensure that your Service user holds enough permissions to query database collection.
If you use more than one database, please provide ClusterId; otherwise, the default database will be used.
GET - Gets all records from Collection "Companies."
import { db } from'codemash';// gets all first 100 employees exportasyncfunctiongetEmployees() {returnawaitdb.getRecords('emplpyees',0,100);}// gets all first 100 active employees// get only first name and last name - projection// sort out by created on date in DESC order. exportasyncfunctiongetActiveEmployees() { constfilter=JSON.stringify({ 'is_active':true });constresponse=awaitdb.getRecords('employees',0,100, { first_name:1, last_name:1 }, filter, { created_on:-1 }); return response;}
var client =newCodeMashClient(apiKey, projectId);var service =newCodeMashRepository<Person>(client);var persons =awaitservice.FindAsync( x =>true,newDatabaseFindOptions());
Check the docs about entities on how the response records are deserialized into your class objects.
Error with https://760328771-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LwSkuCpTNI_AerL8J2a%2Fuploads%2FCpzJktmKXD6FMPSah1nK%2Fopenapi.json?alt=media&token=854cdd6a-61b2-49a5-99f4-6bc091e5c3d6: Failed to convert Swagger 2.0 to OpenAPI 3.0: Operation UpdateManyRequestdbCollectionNamebulk_Update has multiple requestBodies
Error with https://760328771-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LwSkuCpTNI_AerL8J2a%2Fuploads%2FCpzJktmKXD6FMPSah1nK%2Fopenapi.json?alt=media&token=854cdd6a-61b2-49a5-99f4-6bc091e5c3d6: Failed to convert Swagger 2.0 to OpenAPI 3.0: Operation UpdateManyRequestdbCollectionNamebulk_Update has multiple requestBodies