Skip to content

Commit

Permalink
DOC: refine find/get doc
Browse files Browse the repository at this point in the history
Michael O'Brien committed Jun 28, 2024
1 parent d37835c commit e333926
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions docs/api/model/methods.md
Original file line number Diff line number Diff line change
@@ -40,9 +40,11 @@ The optional params are described in [Model API Params](../params).

Find items in the database. This API wraps the DynamoDB `query` method.

The `properties` parameter is a Javascript hash containing the required keys or fields that are used to determine the primary key or keys.
The `properties` parameter is a Javascript hash containing the required keys or fields that are used to determine the primary key or keys.

The sort key may be defined as a simple value or as a key condition by setting the property to an object that defines the condition. The condition operator is specified as the key, and the operand as the value. For example:
When using value templates for key fields, it is preferable to use non-key properties and rely on OneTable to compute the key fields.

If provided, the sort key may be defined as a simple value or as a key condition by setting the property to an object that defines the condition. The condition operator is specified as the key, and the operand as the value. For example:

```javascript
let user = await User.find({pk, sk: {begins: 'user:john'}})
@@ -147,6 +149,8 @@ Get an item from the database. This API wraps the DynamoDB `getItem` method.

The `properties` parameter is a Javascript hash containing the required keys or fields that are used to create the primary key.

When using value templates for key fields, it is preferable to use non-key properties and rely on OneTable to compute the key fields.

Additional fields supplied in `properties` may be used to construct a filter expression. In this case, a `find` query is first executed to identify the item to retrieve. Superfluous property fields will be ignored.

The `get` method returns Javascript properties for the item after applying any schema mappings. Hidden attributes will not be returned.
2 changes: 1 addition & 1 deletion docs/api/table/methods.md
Original file line number Diff line number Diff line change
@@ -121,7 +121,7 @@ The results returned will include hidden properties as they are needed to group

async find(modelName, properties, params = {})

Find an item in the database of the given model `modelName` as defined in the table schema. Wraps the `Model.find` API. See [Model.find](../model/methods/#find) for details.
Find an item in the database of the given model `modelName` as defined in the table schema. Wraps the `Model.find` API. See [Model.find](../../model/methods/#find) for details.


## get

0 comments on commit e333926

Please sign in to comment.