indicted
=========
indicted - Indexed Document Class
Summary
-------
Find an list element, which is a dict, by a keys value
Usage
-----
Take for example the following data. This structure is being used to reduce
relationships between a parent object and sub objects. This allows us to create
indexes that help with relationships rather than making multiple calls to a
database. This is just an example structure of a document. This specific
structure will benifit heavily from a multi-value index on **subdata._id**.
```javascript
{
"_id" : ObjectId("4f3eb7cac4f804960a859467"),
"subdata" : [
{
"_id" : ObjectId("4f3eb7cac4f804960a859468"),
"bits" : 1234
},
{
"_id" : ObjectId("4f3eb7cac4f804960a859469"),
"bits" : 5678
}
]
}
```
If we access the **subdata** key in the root of this document we will be given
an array when using standard Dict/List types.
```python
[{u'_id': ObjectId('4f3eb7cac4f804960a859468'), u'bits': 1234.0},
{u'_id': ObjectId('4f3eb7cac4f804960a859469'), u'bits': 5678.0}]
```
Ideally we would want to return the list element that matches a specific **_id**
if the list contains dictionaries that have a key matching that ObjectId. This
is where indicted and Inist comes in. InDict is a simple Dict wrapper
that uses InList for all list type values. As InList is initialized and
modified it keeps an internal dictionary of **_id** references relating to list
positions. An extra function called **InList.find** is used to pull out a
referenced object if it finds one. **None** is returned otherwise.
```python
import pprint
import pymongo
from bson import ObjectId
from indicted import InDict
class MongoInDict(InDict):
INDEXCLASS = ObjectId
INDEXKEY = '_id'
connection = pymongo.Connection(document_class=MongoInDict)
database = connection.test
data = database.data.find_one()
pprint.pprint(data['subdata'].find(ObjectId('4f3eb7cac4f804960a859469')))
pprint.pprint(data['subdata'].find(ObjectId('000000000000000000000000')))
```
Yields
```python
{u'_id': ObjectId('4f3eb7cac4f804960a859469'), u'bits': 5678.0}
None
```
There is also **indicted.OrderedInDict** that inherits
**collections.OrderedDict**. This is incredibly useful for maintaining the
document key ordering of your documents.
Status
------
Currently this module only creates references during the initialization of the
list. This will be addressed soon.
Todo
----
* Dot notation
* JSON encoding/decoding/pretty printing helpers
=========
indicted - Indexed Document Class
Summary
-------
Find an list element, which is a dict, by a keys value
Usage
-----
Take for example the following data. This structure is being used to reduce
relationships between a parent object and sub objects. This allows us to create
indexes that help with relationships rather than making multiple calls to a
database. This is just an example structure of a document. This specific
structure will benifit heavily from a multi-value index on **subdata._id**.
```javascript
{
"_id" : ObjectId("4f3eb7cac4f804960a859467"),
"subdata" : [
{
"_id" : ObjectId("4f3eb7cac4f804960a859468"),
"bits" : 1234
},
{
"_id" : ObjectId("4f3eb7cac4f804960a859469"),
"bits" : 5678
}
]
}
```
If we access the **subdata** key in the root of this document we will be given
an array when using standard Dict/List types.
```python
[{u'_id': ObjectId('4f3eb7cac4f804960a859468'), u'bits': 1234.0},
{u'_id': ObjectId('4f3eb7cac4f804960a859469'), u'bits': 5678.0}]
```
Ideally we would want to return the list element that matches a specific **_id**
if the list contains dictionaries that have a key matching that ObjectId. This
is where indicted and Inist comes in. InDict is a simple Dict wrapper
that uses InList for all list type values. As InList is initialized and
modified it keeps an internal dictionary of **_id** references relating to list
positions. An extra function called **InList.find** is used to pull out a
referenced object if it finds one. **None** is returned otherwise.
```python
import pprint
import pymongo
from bson import ObjectId
from indicted import InDict
class MongoInDict(InDict):
INDEXCLASS = ObjectId
INDEXKEY = '_id'
connection = pymongo.Connection(document_class=MongoInDict)
database = connection.test
data = database.data.find_one()
pprint.pprint(data['subdata'].find(ObjectId('4f3eb7cac4f804960a859469')))
pprint.pprint(data['subdata'].find(ObjectId('000000000000000000000000')))
```
Yields
```python
{u'_id': ObjectId('4f3eb7cac4f804960a859469'), u'bits': 5678.0}
None
```
There is also **indicted.OrderedInDict** that inherits
**collections.OrderedDict**. This is incredibly useful for maintaining the
document key ordering of your documents.
Status
------
Currently this module only creates references during the initialization of the
list. This will be addressed soon.
Todo
----
* Dot notation
* JSON encoding/decoding/pretty printing helpers
Metadata
Release files for indicted 0.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| indicted-0.0.2.tar.gz | 3.5 kB | Without provenance | Details |
Release files / indicted-0.0.2.tar.gz
| Download URL | indicted-0.0.2.tar.gz |
|---|---|
| Size | 3.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
10a70f885e84d8b1f11dd803e1a1755564722ba44921299cdacdda79ed5b88ea
|
|
BLAKE2b-256 checksum How to use checksums |
5d3e580b84436b17c42cc9119bd30f7c1e6c22158729d94bf93f57c7e747f9c5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for indicted 0.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.