Iterator for BSON objects
Class BSONIter( bson )
bson | A BSON object |
Example:
iter = BSONIter( bson ) while iter.next() doSomething( iter.key(), iter.value() ) end
The iterator copies data from given BSON object, and is completely independant and cannot be changed or updated. (This is of course suboptimal and could be optimized later.)
Methods | |
find | Return true when (and set iterator position where) name is found in the BSON. |
key | Get the current BSON key string |
next | Return true if there is more data to iterate over |
reset | Reset to start of iterator. |
value | Get the current BSON value |
Return true when (and set iterator position where) name is found in the BSON.
BSONIter.find( name )
name | Key name |
Return | True if the key can be found, false otherwise. |
If false is returned, iterator is at end (and you may have to reset it). This method does a reset before searching.
Get the current BSON key string
BSONIter.key()
Return | The current key. |
Return true if there is more data to iterate over
BSONIter.next()
Return | True if the iterator could advance, false if it was the last element. |
Reset to start of iterator.
BSONIter.reset()
Get the current BSON value
BSONIter.value()
Return | The current value. |