MongoDB是无模式的,没有表.在MongoDB中,每个集合可以有不同类型的项.您可以在同一个集合中存储两个非常不同的项目:
db.test.insert( { "SomeString" : "How much wood would the woodchop chop ..." } );
db.test.insert( { "Amount": 2040.20, "Due": new ISODate("2012-11-10"), "UserId" : new ObjectId("...")} );
通常,这些对象以某种方式相关,或者有一个公共的基类型,但这不是必需的.
但是,您可以使用
db.collectionName.findOne()
或
db.collectionName.find().pretty()
However, there's no guarantee from MongoDB that any two rec或ds look alike 或 have the same fields: there's no schema.