Find One

Gets record by specified database unique id or filter.

Finds one database record. 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.

var client = new CodeMashClient(apiKey, projectId);
var service = new CodeMashRepository<Person>(client);

var person = await service.FindOneByIdAsync(
    "{RECORD_ID}",
    new DatabaseFindOneOptions()
);

Check the docs about entities on how the response record is deserialized into your class object.

Check the docs on how to form projections. Check the docs on how to use references.

Find One (by using a filter)

GET https://api.codemash.io/:version/db/:collectionName/findOne

Gets a record by using a filter. This endpoint accepts GET and POST methods.

Path Parameters

Query Parameters

Headers

{
    "result": "{ '_id': '5e37136bf59f3a3f940b99a4', 'name': 'John' }",
    "schema": null,
}
var client = new CodeMashClient(apiKey, projectId);
var service = new CodeMashRepository<Person>(client);

var person = await service.FindOneAsync(
    x => x.Id == "{RECORD_ID}",
    new DatabaseFindOneOptions()
);

Check the docs about entities on how the response record is deserialized into your class object.

Check the docs on how to form projections, filters. Check the docs on how to use references.

Last updated