Т
Returns: A document containing:
A boolean acknowledged as true if the operation ran with write concern or false if write concern was disabled
An array of _id for each successfully inserted documents
Ты хочешь массив _id отсортировать?
Size: a a a
Т
Returns: A document containing:
A boolean acknowledged as true if the operation ran with write concern or false if write concern was disabled
An array of _id for each successfully inserted documents
DS
db.test.insertMany([{test:1},{test:2}])
{
"acknowledged" : true,
"insertedIds" : [
ObjectId("5ea96bd9a0916a4f0c6f4edd"),
ObjectId("5ea96bd9a0916a4f0c6f4ede")
]
}edIds сортировать нужно?Т
db.test.insertMany([{test:1},{test:2}])
{
"acknowledged" : true,
"insertedIds" : [
ObjectId("5ea96bd9a0916a4f0c6f4edd"),
ObjectId("5ea96bd9a0916a4f0c6f4ede")
]
}edIds сортировать нужно?N
DS
mongos> db.test.insertMany([{test:1},{test:2}])
{
"acknowledged" : true,
"insertedIds" : [
ObjectId("5ea96c53743ab1635eb56a41"),
ObjectId("5ea96c53743ab1635eb56a42")
]
}
mongos>DS
Т
Т
DS
DS
DS
y
2020-04-29T10:29:49.232+0200 I STORAGE [initandlisten] ** WARNING: mongod started without --replSet yet 1 documents are present in local.system.replset
2020-04-29T10:29:49.232+0200 I STORAGE [initandlisten] ** Restart with --replSet unless you are doing maintenance and no other clients are connected.
db["system.replset"].remove({})
WriteResult({
"writeError" : {
"code" : 13,
"errmsg" : "not authorized on local to execute command { delete: \"system.replset\", ordered: true, lsid: { id: UUID(\"4f008daf-42eb-469a-9ca8-d5ab3bb6203e\") }, $db: \"local\" }"
}
})
Пробовал сделать свою роль с возможностью делать remove в этой базе (local). Но так тоже нельзя (не дает создать такую роль)N
Т
Т

Т
N
Т
DS
> use local
switched to db local
> db["system.replset"].drop()
2020-04-29T14:37:18.186+0200 E QUERY [thread1] Error: drop failed: {
"ok" : 0,
"errmsg" : "not authorized on local to execute command { drop: \"system.replset\", lsid: { id: UUID(\"f0598b25-9bc5-4aeb-aa99-1f748b948b21\") }, $db: \"local\" }",
"code" : 13,
"codeName" : "Unauthorized"
} :
_getErrorWithCode@src/mongo/shell/utils.js:25:13
DBCollection.prototype.drop@src/mongo/shell/collection.js:695:1
@(shell):1:1
> db.dropDatabase()
{
"ok" : 0,
"errmsg" : "not authorized on local to execute command { dropDatabase: 1.0, lsid: { id: UUID(\"f0598b25-9bc5-4aeb-aa99-1f748b948b21\") }, $db: \"local\" }",
"code" : 13,
"codeName" : "Unauthorized"
}
y
> use local
switched to db local
> db["system.replset"].drop()
2020-04-29T14:37:18.186+0200 E QUERY [thread1] Error: drop failed: {
"ok" : 0,
"errmsg" : "not authorized on local to execute command { drop: \"system.replset\", lsid: { id: UUID(\"f0598b25-9bc5-4aeb-aa99-1f748b948b21\") }, $db: \"local\" }",
"code" : 13,
"codeName" : "Unauthorized"
} :
_getErrorWithCode@src/mongo/shell/utils.js:25:13
DBCollection.prototype.drop@src/mongo/shell/collection.js:695:1
@(shell):1:1
> db.dropDatabase()
{
"ok" : 0,
"errmsg" : "not authorized on local to execute command { dropDatabase: 1.0, lsid: { id: UUID(\"f0598b25-9bc5-4aeb-aa99-1f748b948b21\") }, $db: \"local\" }",
"code" : 13,
"codeName" : "Unauthorized"
}
not authorized