DEV Community

Discussion on: How do you use "find" vs "get" prefix?

Collapse
 
attkinsonjakob profile image
Jakob Attkinson

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.

This helps me, thank you for your time.

Collapse
 
rouilj profile image
John P. Rouillard

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.