mongo

simple pymongo object wrapper

https://github.com/imbolc/mongo

Science Score: 13.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (4.4%) to scientific vocabulary
Last synced: 11 months ago · JSON representation

Repository

simple pymongo object wrapper

Basic Info
  • Host: GitHub
  • Owner: imbolc
  • License: isc
  • Language: Python
  • Default Branch: master
  • Size: 117 KB
Statistics
  • Stars: 6
  • Watchers: 3
  • Forks: 2
  • Open Issues: 1
  • Releases: 0
Created almost 14 years ago · Last pushed over 2 years ago
Metadata Files
Readme License

README.md

mongo

Minimalistic pymongo object wrapper

Document

Minimal document model:

>>> from mongo import Document, Index
>>> class Doc(Document):
...     __database__ = 'mongo_test'  # database name

All allowed settings:

>>> class Doc(Document):
...     __connection__ = {'host': 'localhost', 'port': 27017}
...     #__auth__ = ('username', 'password')
...     __database__ = 'mongo_test' # database name
...     __collection__ = 'test'     # collection name
...     __safe__ = True             # enable safe insert mode
...
...     __indexes__ = [
...         Index('number', unique=True, sparse=True),
...     ]

Clear collection

>>> t = Doc.remove()
>>> Doc.count()
0

Create document

>>> doc = Doc(foo='bar')
>>> doc['number'] = 10
>>> doc.save()
>>> '_id' in doc
True

Fetch

Get by id:

>>> doc1 = Doc.get_by_id(doc.id)
>>> doc1 == doc
True

Find one:

>>> doc2 = Doc.find_one({'number': 10})
>>> doc2 == doc
True

Find:

>>> doc3 = Doc.find({'number': 10}).limit(1)[0]
>>> doc3 == doc
True

Get or create:

>>> doc4, new = Doc.get_or_create({'number': 10}, defaults={'foo': 'bar'})
>>> new
False
>>> doc4 == doc
True

Update

Update filtered documents:

>>> t = Doc.update({'number': 10}, {'$set': {'text': 'foo'}})
>>> doc = Doc.find_one({'number': 10})
>>> doc['text']
u'foo'

Save only some fields:

>>> doc['text'] = u'bar'
>>> doc['number'] = 11
>>> doc.save_fields('text')
>>> doc = Doc.find_one({'number': 10})
>>> doc['text'], doc['number']
(u'bar', 10)

Update only some fields:

>>> doc.atomic_update({'$inc': {'number': 2}})
>>> doc = Doc.find_one({'text': 'bar'})
>>> doc['number']
12

Counting

>>> Doc().save()
>>> Doc.count()
2
>>> Doc.find({'number': 12}).count()
1

Delete

Remove single document:

>>> t = doc.delete()
>>> Doc.find_one({'number': 12})

Remove some documents:

>>> t = Doc.remove({'number': 10})

Remove all documents:

>>> t = Doc.remove()

Owner

  • Name: Imbolc
  • Login: imbolc
  • Kind: user

GitHub Events

Total
Last Year

Committers

Last synced: over 1 year ago

All Time
  • Total Commits: 7
  • Total Committers: 1
  • Avg Commits per committer: 7.0
  • Development Distribution Score (DDS): 0.0
Past Year
  • Commits: 0
  • Committers: 0
  • Avg Commits per committer: 0.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Imbolc i****c@i****e 7
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 11 months ago

All Time
  • Total issues: 0
  • Total pull requests: 1
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Total issue authors: 0
  • Total pull request authors: 1
  • Average comments per issue: 0
  • Average comments per pull request: 0.0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
Pull Request Authors
  • suresh87 (2)
Top Labels
Issue Labels
Pull Request Labels

Packages

  • Total packages: 1
  • Total downloads:
    • pypi 23,133 last-month
  • Total docker downloads: 107,992
  • Total dependent packages: 1
  • Total dependent repositories: 198
  • Total versions: 6
  • Total maintainers: 1
pypi.org: mongo

Minimalistic pymongo object wrapper

  • Homepage: https://github.com/imbolc/mongo
  • Documentation: https://mongo.readthedocs.io/
  • License: Copyright (c) 2012 Imbolc Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  • Latest release: 0.2.0
    published almost 14 years ago
  • Versions: 6
  • Dependent Packages: 1
  • Dependent Repositories: 198
  • Downloads: 23,133 Last month
  • Docker Downloads: 107,992
Rankings
Dependent repos count: 1.1%
Docker downloads count: 1.6%
Downloads: 1.7%
Dependent packages count: 4.7%
Average: 8.5%
Stargazers count: 19.3%
Forks count: 22.6%
Maintainers (1)
Last synced: 11 months ago

Dependencies

setup.py pypi
  • pymongo *