isage / lua-resty-moongoo

MongoDB library for OpenResty
Do What The F*ck You Want To Public License
118 stars 33 forks source link

Force writing array instead of object? #17

Closed travisbell closed 6 years ago

travisbell commented 6 years ago

Hey man,

I know you mentioned in the docs that for now you decided to store empty tables as objects instead of arrays. I wonder, would it be possible to have a cbson type to force the storage as a cbson array instead? Kind of like what you did with storing nil?

isage commented 6 years ago

Sure. I've added cbson.array() to lua-cbson.

travisbell commented 6 years ago

Awesome man, thanks! 👍

travisbell commented 6 years ago

Hey @isage I've just been trying to use this and can't seem to get it to work. Trying to store a cbson.array() seems to just silently fail and I can't figure out where the issue is.

Do you have a working example that I can see?

isage commented 6 years ago

It looks like mongo libbson doesn't like BSON_APPEND_ARRAY with empty arrays and segfaults. Fixed in latest commit to lua-cbson

travisbell commented 6 years ago

Yup, looks good. It's not segfaulting anymore. Thanks.