Native Mongo Shell became available as In-Preview mode in Azure Cosmos DB on March. I had chance to check it out this week and I decided to write about it this week. Mongo Shell let you execute Mongo database commands in Cosmos DB Data Explorer! Currently, It is not available in all Azure regions. If you don't see this option, your database might be in a region that does not support this option yet.
Click on Data Explorer to see the Mongo Shell button. If you have never used it before, you will need to activate the Mongo Shell by clicking Complete Setup button. This box will open up when you click on Open Mongo Shell.
You need to do this once. When setup is complete, you should be able to see/open the Mongo Shell with no problem. When it opens, it looks like this.
You might be saying "We have the Mongo Shell, Now what? What can we do with this?" This version is still In-Preview so keep your expectations low for now. This is the first step to have something awesome in the future. You can run the following commands, these are specific to Cosmos DB.
- CreateDatabase
- UpdateDatabase
- GetDatabase
- CreateCollection
- UpdateCollection
- GetCollection
CREATE DATABASE
We need to use "use" command to specify the name of the new database, then send the create database command to the shell. It is little confusing since you need to use "use" command for not exist database. Here how it works.
Font size is small, if you have vision problems, you may not be fan of this UI.
use shelltest
db.runCommand({customAction:"CreateDatabase",offerThroughput: 400})
UPDATE DATABASE
Update Database command can update only the threshold(Request Unit) settings of a database.
Here how to use it.
use shelltestdb.runCommand({customAction:"UpdateDatabase",offerThroughput: 600})GET DATABASE
As you might guess, this command returns the information about a database.use shelltestdb.runCommand({customAction:"GetDatabase"})
CREATE COLLECTION
You can create collection by using this command. In the following example, I try to create a Mongo DB Collection named TestCol but I couldn't. In the documentation It says, I should be able to create a collection without specifying a partition key.
I contacted to Cosmos DB team about this and I will update this post when I get an answer from them.
use shelltestdb.runCommand({customAction:"CreateCollection",collection:"TestCol", offerThroughPut: 400})
If you specify a shardkey (PartitionId), It works.
UPDATE COLLECTION
Just like updatedatabase command this command can update only the threshold property. In the following example, I update the request unit setting to 800use shelltestdb.runCommand({customAction:"UpdateCollection",collection:"TestCol", offerThroughput: 800})GET COLLECTION
This command gives us information about a collection.use shelltestdb.runCommand({customAction:"GetCollection",collection:"TestCol"})Rather than these Cosmos DB specific commands. You can use Mongo DB commands in the shell. Here are some examples.db.TestCol.insert({id:"1", name: "Hasan Savran"})db.TestCol.insertMany([{id:"2", name: "Alec Savran"},{id:"3", name:"Avery Savran"}])
Blackjack Casino - Mapyro
ReplyDeletePlay Blackjack for real money 창원 출장샵 at Blackjack. Find the best blackjack table games near 전라남도 출장마사지 you, 원주 출장샵 or start gambling on your favorite table games. Rating: 4.2 · 당진 출장마사지 14 포항 출장안마 votes