#MDB- MongoDB Models
[](https://travis-ci.org/RevelutionWind/MDB)
[](http://badge.fury.io/py/mondb)
[](https://pypi.python.org/pypi/mondb)
[](https://landscape.io/github/RevelutionWind/MDB/master)
##Installation
You can install mondb from its official pypi repository.
```
pip install mondb
```
##Models
Inorder to create a Model you first need to inherit Document class in Mondb
```python
from mondb.Connection import create_engine
import mondb
#used to establish a connection with the collection
create_engine(database ="Management", host= "localhost", port=27017)
class User(mdb.Document):
name = mondb.StringProperty()
age = mondb.IntegerProperty()
m = User(name = "sathya", age =23)
m.save()
```
##Searching and Updating
In most of the case where the user needs to search and update models.
Mondb comes with methods such as <b>search()</b> and <b>find()</b> for finding
a document from the collection.
```python
#search returns a matching records as pymongo cursor.
cursor = User.search(name="sathya")
# Note:
# cursor is not a list but can be indexed. use list(cursor) if you want to use
# it as a list
for record in cursor:
print record
```
##Query
Mondb also comes with a Query object where you can Query with some
criteria.
```python
query = mondb.Query(User)
query.filter("age", ">=", 20)
lst = query.fetch()
for l in lst:
print l
```
Methods such as <b>filter()</b> and <b> fetch()</b> will be handy for getting results from
the query.
##Deleting
Mondb models can be deleted with the help of <b> delete() </b> method.
```python
user = User.search(age=23)[0]
user.delete()
```
##License
<h4>MIT</h4>
[](https://travis-ci.org/RevelutionWind/MDB)
[](http://badge.fury.io/py/mondb)
[](https://pypi.python.org/pypi/mondb)
[](https://landscape.io/github/RevelutionWind/MDB/master)
##Installation
You can install mondb from its official pypi repository.
```
pip install mondb
```
##Models
Inorder to create a Model you first need to inherit Document class in Mondb
```python
from mondb.Connection import create_engine
import mondb
#used to establish a connection with the collection
create_engine(database ="Management", host= "localhost", port=27017)
class User(mdb.Document):
name = mondb.StringProperty()
age = mondb.IntegerProperty()
m = User(name = "sathya", age =23)
m.save()
```
##Searching and Updating
In most of the case where the user needs to search and update models.
Mondb comes with methods such as <b>search()</b> and <b>find()</b> for finding
a document from the collection.
```python
#search returns a matching records as pymongo cursor.
cursor = User.search(name="sathya")
# Note:
# cursor is not a list but can be indexed. use list(cursor) if you want to use
# it as a list
for record in cursor:
print record
```
##Query
Mondb also comes with a Query object where you can Query with some
criteria.
```python
query = mondb.Query(User)
query.filter("age", ">=", 20)
lst = query.fetch()
for l in lst:
print l
```
Methods such as <b>filter()</b> and <b> fetch()</b> will be handy for getting results from
the query.
##Deleting
Mondb models can be deleted with the help of <b> delete() </b> method.
```python
user = User.search(age=23)[0]
user.delete()
```
##License
<h4>MIT</h4>
Release files for mondb 0.0.5.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 | |
|---|---|---|---|
| mondb-0.0.5.2.tar.gz | 10.9 kB | Details |
Release files / mondb-0.0.5.2.tar.gz
| Download URL | mondb-0.0.5.2.tar.gz |
|---|---|
| Size | 10.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8e750d66ae2c8d290b0cbb809549628b81edf46c65a96259a88957f81893ee8b
|
|
BLAKE2b-256 checksum How to use checksums |
c61eda528aa9f86b44c92f8691eb2d4ef33252ee1c8be1eec7796795a5763200
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |