Comments (3)
It's possible. Have you read the docs before opening the issue?
https://github.com/neoxic/lua-mongo/blob/master/doc/main.md#mongobsonvalue
from lua-mongo.
Oh, I missed that adding __array is required. It's poor requirement. Few json libs I had worked with was able to handle it transparently.
I'm replacing simple json storage with mongo and data is not tagged with __array nor it will be generated with it. So it seems I have to tag arrays manually before passing to lua-mongo.
from lua-mongo.
It's a very powerful requirement that helps avoid ambiguity. Let's suppose you have a table {[1] = 1, [3] = 3, [5] = 5}
that maps one group of IDs to another. If treated automatically, it needs to be stored as {"1": 1, "3": 3, "5": 5}
in JSON/BSON. And then it happens that two pairs are added to it - [2] = 2
and [4] = 4
. Oops! Your table has suddenly become an indexed array in Lua and, if treated automatically, will be stored in JSON/BSON incorrectly as [1, 2, 3, 4, 5]
.
On the other hand, prohibiting automatic numeric key conversions and having an explicit indexed array marker __array
helps avoid a great deal to subtle bugs like that.
Furthermore, if you wish to mark your tables with __array
automatically on the fly, you can always do that using the __toBSON
metamethod. This way, you are free to implement any indexed array autodetection policy as you see fit. It is much more flexible than having a "one size fits all" built-in strategy for detecting indexed arrays.
from lua-mongo.
Related Issues (20)
- Requiring the library from Lua results in error ("undefined symbol: lua_tointeger") HOT 12
- Find method how to select the specified column? HOT 1
- have a question HOT 1
- Install error HOT 5
- undefined symbol: mongoc_collection_replace_one HOT 4
- i have problem guy.how to find or aggregation ISODate. HOT 1
- Compile error HOT 2
- nginx content_by_lua_block gives an error if ssl is used HOT 3
- Process aborts due to a zero server_id HOT 1
- Session support HOT 4
- Unable to install lua-mongo with luarocks HOT 2
- insertOne question HOT 1
- cant get build via luarocks in windows HOT 1
- How to install on Windows? HOT 3
- When mongo has username and password, how can I do? HOT 2
- How to create a TTL index? HOT 4
- Lua-mongo can't be used with mongo-c-driver_v1.19 HOT 2
- building with luarocks mingw64 HOT 7
- The specified module could not be found? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lua-mongo.