如何通过命令行连接到我的MongoDB表?
为了通过命令行连接到我的表,您需要使用db命令
db.yourCollectionName.find();
假设我们有一个带有一些集合的数据库“样本”。首先检查当前数据库
> use sample; switched to db sample > db; Sample Now we have reached the database sample. The database “sample” is having the following collections: > show collections;
这将产生以下输出
arraySizeErrorDemo basicInformationDemo copyThisCollectionToSampleDatabaseDemo deleteAllRecordsDemo deleteDocuments deleteDocumentsDemo deleteSomeInformation documentWithAParticularFieldValueDemo employee findListOfIdsDemo findSubstring getAllRecordsFromSourceCollectionDemo getElementWithMaxIdDemo internalArraySizeDemo largestDocumentDemo makingStudentInformationClone oppositeAddToSetDemo prettyDemo returnOnlyUniqueValuesDemo selectWhereInDemo sourceCollection studentInformation sumOfValueDemo sumTwoFieldsDemo truncateDemo updateInformation userInformation
这是连接到表(即集合)的正确方法。您需要使用db命令。以下是查询
> db.userInformation.find();
这将产生以下输出
{ "_id" : ObjectId("5c6a765964f3d70fcc9147f5"), "Name" : "John", "Age" : 30, "isStudent" : false, "Subjects" : [ "Introduction to java", "Introduction to MongoDB" ] }热门推荐
10 香港老妈结婚祝福语简短
11 毕业立体贺卡祝福语简短
12 简短新年年会祝福语
13 评论小品祝福语大全简短
14 恭喜师兄结婚祝福语简短
15 员工集体辞职祝福语简短
16 高中新生祝福语 简短
17 装修祝福语男生搞笑简短
18 生日开业蛋糕祝福语简短