nightroman / Mdbc

MongoDB Cmdlets for PowerShell
Apache License 2.0
141 stars 16 forks source link

Unable to get collection #71

Closed Azizalorabi closed 2 years ago

Azizalorabi commented 2 years ago

Hi nightroman Thank you very much for this useful tool. I don't think this is an issue , maybe I dont know yet hoe to use Mdbc. I am using Mac M1 visual studio > Powershell core. When I try to connect to MongoDB I just use the following: Import-Module Mdbc Connect-Mdbc -ConnectionString mongodb://127.0.0.1:27017 Get-MdbcDatabase

And I can see the databases but if I want to see the collection inside a database I got nothing no error (IP_LOOKUP is the name of the collection): Get-MdbcCollection No result no error

Get-MdbcCollection -Name IP_LOOKUP --- this is the result: CollectionNamespace : test.IP_LOOKUP Database : MongoDB.Driver.MongoDatabaseImpl DocumentSerializer : MongoDB.Bson.Serialization.Serializers.BsonDocumentSerializer Indexes : MongoDB.Driver.MongoCollectionImpl`1+MongoIndexManager[MongoDB.Bson.BsonDocument] Settings : AssignIdOnInsert=True;GuidRepresentation=Standard;ReadConcern={ };ReadEncoding=null;ReadPreference={ Mode : Primary };WriteConcern={ };WriteEncoding=null

But makes no sense to me. I will try later to insert data inside the collection but I can't get it yet :)

nightroman commented 2 years ago

If you need Get-MdbcCollection to return collections you should either specify the database or use Connect-Mdbc with a database name specified as the parameter.

Azizalorabi commented 2 years ago

I tried (DarknessEye is the name of the DB): Import-Module Mdbc Connect-Mdbc -ConnectionString mongodb://127.0.0.1:27017 Get-MdbcCollection DarknessEye

Result shows : CollectionNamespace : test.DarknessEye Database : MongoDB.Driver.MongoDatabaseImpl DocumentSerializer : MongoDB.Bson.Serialization.Serializers.BsonDocumentSerializer Indexes : MongoDB.Driver.MongoCollectionImpl`1+MongoIndexManager[MongoDB.Bson.BsonDocument] Settings : AssignIdOnInsert=True;GuidRepresentation=Standard;ReadConcern={ };ReadEncoding=null;ReadPreference={ Mode : Primary };WriteConcern={ };WriteEncoding=null

nightroman commented 2 years ago

Have you taken a look at the help? E.g. help Connect-Mdbc -full etc. You should use a command like this, to connect to a database:

Connect-Mdbc -ConnectionString mongodb://127.0.0.1:27017 -DatabaseName DarknessEye
nightroman commented 2 years ago

This command is not supposed to show anything. Can you get the complete sequence of commands and expected/actual results for each?

Azizalorabi commented 2 years ago

Yes It worked out! Now It makes sense to me. Can you keep the issue open please until I can insert documents? and get back to you if there is any issue :) I will use help New-MdbcData -Full , I promise :)

Azizalorabi commented 2 years ago

This works perfectly Thank you!

nightroman commented 2 years ago

You are very welcome! I am closing this one. Feel free to open another issue.