bigplum / lua-resty-mongol

A ngx_lua driver for mongodb -- Deprecated for not updating with the mongodb version
198 stars 67 forks source link

UNABLE to initialize a key in a document with an empty array! #66

Open L-maple opened 5 years ago

L-maple commented 5 years ago

The background is that, the Lua's table type symbolize array and table both. So if I want to initialize a key in a document with {}, the value inserted is a table{} rather than a array []!! That brings many problems, for example: local ret, err = exam_group_db:update({_id = _old_group_id}, {['$pushAll'] = {users = v_param.examinee_ids}}) if key users in the document is {}, the operation above will not work!!! Only if users 's value is [], the operation can work. So how should I solve this problem? Thanks!