You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The proposal is to make count work on strings and binary data in addition to arrays.
On binary data it would count the number of bytes, and on string data I propose it would count the number of UTF-8 code points.
Not sure if this belongs in a separate issue, but I also think <object>.count() should return the number of keys. Basically a shortcut to <object>.keys().count() or <object>.coerceTo('array').count().
I would like to propose that we also define count on objects and have it count the number of fields. I think most languages that have a common function that works on arrays and strings also define that function on objects.
Activity
danielmewes commentedon May 13, 2015
An alternative is to introduce another term
lengthfor strings. I would prefer re-usingcount.coffeemug commentedon May 16, 2015
Obligatory reminder that
countalready works on binary blobs:carbureted commentedon Jun 29, 2015
Would be awesome to see this!
andreis commentedon Jul 22, 2015
I need to measure the byte size of documents, currently I'm doing
Is that good enough?
mlucy commentedon Jul 23, 2015
@andreis -- yeah, that should get you the size of the JSON representation of the document.
marshall007 commentedon Jul 23, 2015
Not sure if this belongs in a separate issue, but I also think
<object>.count()should return the number of keys. Basically a shortcut to<object>.keys().count()or<object>.coerceTo('array').count().danielmewes commentedon Jul 24, 2015
@marshall007 Ah that's an interesting idea. I quite like that (though I haven't thought about it too deeply yet).
mlucy commentedon Aug 27, 2015
So the current proposal is just to define
counton strings? That seems obviously good to me, so +1.mlucy commentedon Aug 27, 2015
I would like to propose that we also define
counton objects and have it count the number of fields. I think most languages that have a common function that works on arrays and strings also define that function on objects.VeXocide commentedon Aug 27, 2015
+1 for extending it to support both strings and objects
deontologician commentedon Aug 27, 2015
+1 for objects as well
danielmewes commentedon Aug 27, 2015
Sounds reasonable. 👍 for:
object.count()to count the number of fields andstring.count()to count Unicode code pointscoffeemug commentedon Aug 27, 2015
👍
danielmewes commentedon Sep 3, 2015
Marking as settled as described (
object.count()andstring.count()).encryptio commentedon Dec 4, 2015
In CR 3389
ReQL: support object.count() and string.count()