`open collection default template` not work at some circumstances

shuataren shared this problem 35 days ago
Cannot Reproduce

Here is my `open collection default template`:

/cdff4f7791ddf0b7d7578365026a075f


But when i double click at some db's collections, i will get this:


/8cbf193bca0f8ff8961bb7206c7b3a63

the `.sort({_id: -1})` line is auto commented.


This problem only occurs to some specific db connections, others will obey the template settings.

Best Answer
photo

It looks strange, could you give me a full screenshot?

Comments (13)

photo
1

If the collection "testtesttest1" has no "_id" index, the ".sort({_id:1})" line will be commented.

Could you please show the script result "db.testtesttest1.getIndexes();"?

photo
1

{
	"ns" : "testdb.testtesttest1",
	"v" : 1,
	"key" : {
		"_id" : 1
	},
	"name" : "_id_"
}

photo
1

And i am using the latest version

/6be130d8b1c21d14bb07c874efe1c00d

photo
1

Thanks for your feedback.

Could you please run the script "db.getCollection("testtesttest1").stats().indexSizes" in the NoSQLBooster and show the result?

photo
1

{
	"_id_" : 36864
}

photo
1

We have worked out a test build to resolve the issue, please download and give it a try.

mac os: https://s3.mongobooster.com/download/releasesv5/nosqlbooster4mongo-5.1.6-beta.1.dmg

photo
1

I tried, not solving my problem.

Also i do not think its a problem related to index, cause when i remove the projection in template:

db.%%collection%%.find({$1})
   .sort({_id:-1})
   .limit(%%limit%%)
i still get this, it just dont apply the template config. And still the problem only occurs to specific connections.

db.testtesttest1.find({})
    .projection({})
    //.sort({_id:-1})
    .limit(100)

photo
1

Thank you for your fast feedback.

The reason we check the index is that some collection(e.g. local.oplog.rs) may not have an _id index, which causes the error to open the collection. Your collection has _id index, I don't quite understand why the sort is commented out.

Because it cannot be reproduced locally, tracking problems like this are indeed less efficient. Could you please give me a screenshot including the indexes node like the following picture?

/e6d3f75c03f10a7a23e0c8690839e65c

photo
1

And, If the indexes node has "_id_" child node, please focus to connection tree (left pane), press "CTRL+ALT+SHIFT+F7" to toggle developer toolbar and open the test collection, are there any logged info?

photo
1

/ace04c2a70abfa8e23a8e039844536e2

/2eea6c52b05ff33d27a9f36f3eb4ca97

photo
1

It looks strange, could you give me a full screenshot?

photo
1

Sorry i cant, it will contain privacy info.

photo
1

The problem of not being able to reproduce locally is difficult to locate, I will set the problem to not reproduce, and if there is a complete reproduction step, I will come back.

photo