Object.bsonsize(db.Likes.find({Id: HexData(3, "dfa2eae902cb324487e01b6ddd9de085")}))
Object.bsonsize(db.Likes.find({Id: HexData(3, "248b85402e4f9e4591ad6375ff76dbef")}))
return to me equals result:
but on first document i have nested array with 1 element , second nested array with 5 elements
Stennie_X
(Stennie)
September 21, 2021, 12:28pm
#2
Hi @alexov_inbox ,
The db.collection.find()
method returns a cursor which has to be iterated to get the results .
Since it looks like you are trying to compare the size of individual documents, try using db.collection.findOne()
instead (which returns a document instead of a cursor):
Object.bsonsize(db.Likes.findOne({Id: HexData(3, "dfa2eae902cb324487e01b6ddd9de085")}))
Object.bsonsize(db.Likes.findOne({Id: HexData(3, "248b85402e4f9e4591ad6375ff76dbef")}))
Alternatively you can iterate the find()
cursor using toArray()
:
Object.bsonsize(db.Likes.find({Id: HexData(3, "dfa2eae902cb324487e01b6ddd9de085")}).toArray())
Object.bsonsize(db.Likes.find({Id: HexData(3, "248b85402e4f9e4591ad6375ff76dbef")}).toArray())
Note: using toArray()
will add a few extra bytes to the result (as compared to findOne()
) because it is wrapped as an array.
Regards,
Stennie
2 Likes
yes its work ! thx !
it remains to deal with the fundamental problem
Hello i use bucket pattern for collection , bucket by 10 count
{
blog_id: 12345,
created: '2021-10-03'
posts: [
{
post_id: 222,
text: 'wasd',
created: '2021-10-10'
},
…
],
post_count: 10,
}
On site i first show newest(latest) posts 10 count per page. its all okey if buckets full
10 | 10 | 10 | 10
buy late i add new post and created new bucket
1 | 10 | 10 | 10 | 10
now if i take 1 bucket i get 1 post ! but w…
system
(system)
Closed
September 27, 2021, 6:19am
#4
This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.