doc.bsonsize()
-aj
--
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To post to this group, send email to mongod...@googlegroups.com.
To unsubscribe from this group, send email to mongodb-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.
Hi,
I work with the PHP-Driver, and can´t find the method bsonsize().
> Hi,
> I work with the PHP-Driver, and can´t find the method bsonsize().
There is a function the driver called bson_encode:
http://php.net/manual/en/function.bson-encode.php
You can use that to do:
$len = strlen( bson_encode( $yourDocument ) );
cheers,
Derick
--
http://mongodb.org | http://derickrethans.nl
twitter: @derickr and @mongodb
--
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To view this discussion on the web visit https://groups.google.com/d/msg/mongodb-user/-/eGF6e1IwIoUJ.
On Sat, 28 Jan 2012, Sam Millman wrote:
> Indeed that could will work, but this should really be made into the
> public api cos it is in the driver (they do calc the size of the doc
> there).
If you mean the PHP driver with "public API", why do you think that
strlen(bson_encode($document)); is not a good enough approach for this?
Personally, I don't expect that this is a feature that many people will
need, but feel free to (try to) convince me.
--
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
Object.bsonsize(doc)
in the MongoDB shell?
> On Jan 29, 2:25 am, Sam Millman <sam.mill...@gmail.com> wrote:
>> Knowing the size of a document in MB (or KB) before saving can be very
>> useful for certain restrictions in schema designs.
>>
>> Well strlen() wouldnt be very useful since the size (in MB or KB on disk)
>> cannot be accurately determined from the amount of characters in a encoded
>> BSON string.
>>
>> Thing is this is provided freely in the JS driver just seems a bit weird
>> that its not in most other drivers.
>>
>> On 28 January 2012 14:47, Derick Rethans <der...@10gen.com> wrote:
>>
>>> Hi!
>>
>>> On Sat, 28 Jan 2012, Sam Millman wrote:
>>
>>>> Indeed that could will work, but this should really be made into the
>>>> public api cos it is in the driver (they do calc the size of the doc
>>>> there).
>>
>>> If you mean the PHP driver with "public API", why do you think that
>>> strlen(bson_encode($document)); is not a good enough approach for this?
>>> Personally, I don't expect that this is a feature that many people will
>>> need, but feel free to (try to) convince me.
Best regards/Mit freundlichen Grüßen
--
Muharem Hrnjadovic <m...@foldr3.com>
Public key id : B2BBFCFC
Key fingerprint : A5A3 CC67 2B87 D641 103F 5602 219F 6B60 B2BB FCFC