Skip to main content

Posts

Showing posts with the label NoSQL

Database manipulation in MongoDB

Database manipulation in MongoDB Basic database queries for MongoDB The remove() Method Syntax: >db.COLLECTION_NAME.remove(DELLETION_CRITTERIA) Example: >db.Employee.remove({'title':'MongoDB Overview'}); Remove Only One Syntax: >db.COLLECTION_NAME.remove(DELETION_CRITERIA,1) And/OR Condition >db.Employee.find({$and:[{"by":"Sudhir"},{"title": "Testing MongoDB Database"}]}) >db.Employee.find({$or:[{"by":"Sudhir"},{"title": "Testing MongoDB Database"}]}) Using AND and OR Together >db.mycol.find({"likes": {$gt:10}, $or: [{"by": "Sudhir"},{"title": "Testing MongoDB Database"}]}) The save() method replaces the existing document with the new document passed in the save() method. Syntax: >db.COLLECTION_NAME.save({_id:ObjectId(),NEW_DATA}) Example: >db.mycol.save( { "_id" : Objec...

Beginner guide to Mongodb database

Beginner guide to Mongodb database MongoDB is an open-source document database that provides high performance, high availability, and automatic SCALING . MongoDB documents are similar to JSON objects. MongoDB stores data in the form of BSON -Binary encoded JSON documents which supports a rich collection of types. Fields in BSON documents may hold arrays of values or embedded document s. Structural aspects of MongoDB 1. Data Model A record in MongoDB is a document, which is a data structure composed of field and value pairs. MongoDB stores documents in collections.Collections are analogous to tables in relational databases.  Documents stored in a collection must have a unique _id field that acts as a primary key.  There are two ways to stores documents in a collection either in Normalized for or embedded into another document itself. a) Normalized Data Models The relationships between data is stored by links (references) from one document to another.   ...