在Studio3T中,我创建了一个集合,在其中添加一个文档,然后弹出窗口出现,标题为>>Insert JSON Document<<,以在文档中添加数据,然后编写这些项。
{
"_id" : "5c18e1892998bdb3b3d355bf",
"title" : "REST",
"content" : "REST is short for REpresentational State Transfer. IIt's an architectural style for designing APIs."
}
{
"_id" : ObjectId("5c139771d79ac8eac11e754a"),
"title" : "API",
"content" : "API stands for Application Programming Interface. It is a set of subroutine definitions, communication protocols, and tools for building software. In general terms, it is a set of clearly defined methods of communication among various components. A good API makes it easier to develop a computer program by providing all the building blocks, which are then put together by the programmer."
}
{
"_id" : ObjectId("5c1398aad79ac8eac11e7561"),
"title" : "Bootstrap",
"content" : "This is a framework developed by Twitter that contains pre-made front-end templates for web design"
}
{
"_id" : ObjectId("5c1398ecd79ac8eac11e7567"),
"title" : "DOM",
"content" : "The Document Object Model is like an API for interacting with our HTML"
}
{
"_id" : "5c18f35cde40ab6cc551cd60",
"title" : "Jack Bauer",
"content" : "Jack Bauer once stepped into quicksand. The quicksand couldn't escape and nearly drowned.",
"__v" : 0
}
之后,当我单击add按钮时,将出现另一个名为>>JSON Validation<<的弹出窗口,其中显示“在第8行检测到的Orphan字符”。我无法立即插入这些文件。
如何在文档中同时插入所有这些对象?
发布于 2022-05-30 08:17:22
这是一个限制,在日期之前是不支持的。您可以运行一个insertMany
查询
db.collection.insertMany([{doc1}, {doc2}])
或者,如果不想运行直接查询,则可以导入文档。
发布于 2022-07-02 18:36:09
当我试图同时插入多个对象时,我也面临着同样的问题。我的解决方案是单独添加对象。它知道这需要时间,但我找不到其他方法去做。
发布于 2022-05-31 08:12:12
将JSON文档复制到剪贴板,然后转到集合和控制/命令V,将剪贴板粘贴到集合中。提示您“从剪贴板导入文档”-单击OK,完成后,刷新视图以查看新导入的文档。
背景:正如它所说的,Insert JSON文档用于单个JSON文档。您所看到的错误是因为它检测到第二个JSON文档开始。导入更好地处理多个JSON文档插入,如果将JSON文档粘贴到集合中,它会自动从剪贴板触发导入。
https://stackoverflow.com/questions/72431087
复制相似问题