My take is use get to retrieve an object by providing a unique identifier. It returns the object or an error (object not found).
Find is used to search for some property of the object
and either returns identifier or identifiers (for use with get) for matching objects. It could also return the objects directly but I don't like that quite as much. It can also return none/and empty list indicating nothing matches the find/search request.
E.g. get the book at this specific location from the shelf compared to find all books that are red and have the words moby in the title.
That's similar to my examples, with the main difference that you wouldn't use get to retrieve anything from the DB, but rather use it on an existing collection that was retrieved using find.
As ecyrbe said below, get would be used to retrieve from a DB using the primary key. Finding the primary key based on properties of the object would be the job of find. In your case I assume "id: number" is a unique identifier, so I would use get.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
My take is use get to retrieve an object by providing a unique identifier. It returns the object or an error (object not found).
Find is used to search for some property of the object
and either returns identifier or identifiers (for use with get) for matching objects. It could also return the objects directly but I don't like that quite as much. It can also return none/and empty list indicating nothing matches the find/search request.
E.g. get the book at this specific location from the shelf compared to find all books that are red and have the words moby in the title.
That's similar to my examples, with the main difference that you wouldn't use
get
to retrieve anything from the DB, but rather use it on an existing collection that was retrieved usingfind
.This helps me, thank you for your time.
As ecyrbe said below, get would be used to retrieve from a DB using the primary key. Finding the primary key based on properties of the object would be the job of find. In your case I assume "id: number" is a unique identifier, so I would use get.