top of page

Describing CRUD - Part 6

There are four operations we need to talk about. All databases, whether they be traditional relational database systems, or NoSQL, they all require what are called CRUD operations. CRUD is an acronym that stands for Create, Read, Update and Delete. These operations are the fundamentals for all interactions within a database.

MongoDB queries are very flexible in providing these operations. First of all, they give you the option of targeting a specific collection of documents, within the database. And you can specify a criteria to identify the documents returned. MongoDB gives you something very interesting and very useful. It’s called a projection. It’s essentially a document that defines the search parameters, for want of a better term. So you’re using a document itself as the search parameter to query the database, and return data. MongoDB queries can target a specific collection of documents, specify criteria to identify the documents returned, and include a “projection.” Optional modifiers can be used to limit, skip, or sort the order of results. Now much like SQL databases, MongoDB has some modifiers to a query. You can use various modifiers – which we’ll see a little later – to limit the response, to skip certain records, and to choose how you sort it. For example, if I’m returning documents that mostly have 5 fields, I can sort based on any one of those fields, and in ascending or descending order. So you’ve got a lot of flexibility when you’re creating a query, but perhaps the projection may be the most interesting of those flexible options you have available to you. You could also modify the data. Just the create, update, and delete do this. Data is usually modified in a single collection. You modify one or more records at a time as a collection. Now that collection could be a single document, or it could be multiple documents. It’s usually a good idea to do modifications on a single document at a time, to ensure you don’t accidentally modify records you didn’t intend to.

RECENT POSTS

FEATURED POSTS

Check back soon
Once posts are published, you’ll see them here.

FOLLOW US

  • Grey Facebook Icon
  • Grey Twitter Icon
  • Grey Instagram Icon
  • Grey Google+ Icon
  • Grey Pinterest Icon
bottom of page