如何在MongoDB中正确创建集合,以避免出现“ ReferenceError:未定义”错误?
要正确创建一个集合,您需要在调用中使用MongoDB对象,即
db.createCollection("yourCollectionName");让我们实现以上语法,以创建一个集合并使用MongoDB对象调用它-
> use sample;
switched to db sample
> db.createCollection("employeeInformation");
{ "ok" : 1 }显示来自上面的“样本”数据库的所有集合-
> db.getCollectionNames();
这将产生以下输出-
[ "arraySizeErrorDemo", "atleastOneMatchDemo", "basicInformationDemo", "combinedAndOrDemo", "convertSQLQueryDemo", "copyThisCollectionToSampleDatabaseDemo", "countOrSizeDemo", "distinctOnMultipleFieldsDemo", "documentWithAParticularFieldValueDemo", "employee", "employeeInformation", "findListOfIdsDemo", "findMimimumElementInArrayDemo", "findSubstring", "getAllRecordsFromSourceCollectionDemo", "getElementWithMaxIdDemo", "insertDocumentWithDateDemo", "internalArraySizeDemo", "keepTwoColumnsUniqueDemo", "largestDocumentDemo", "makingStudentInformationClone", "nestedArrayDemo", "oppositeAddToSetDemo", "prettyDemo", "projectionAnElementDemo", "replacingEntireDocumentDemo", "returnOnlyUniqueValuesDemo", "searchInInnerDemo", "selectItemDemo", "selectWhereInDemo", "sourceCollection", "specificFieldDemo", "studentInformation", "sumOfValueDemo", "sumTwoFieldsDemo", "truncateDemo", "updateFieldIfValueIsGreaterDemo", "updateInformation", "updateSubObjectDemo", "userInformation" ]
热门推荐
8 祝福语简短古诗词
10 医政科祝福语简短
11 祝女性生日祝福语简短
12 长辈钻石婚祝福语简短
13 虎年公司祝福语简短的
14 女朋友考试祝福语简短
15 微信晚上祝福语简短
16 老公开业祝福语简短
17 妹妹生日祝福语简短唯美
18 简短朋友旅行祝福语大全