Giter Site home page Giter Site logo

mongothon's People

Contributors

eriktaubeneck avatar inlinestyle avatar justom avatar nrschultz avatar paetling avatar thieman avatar tleach avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mongothon's Issues

Import error

I'm importing create_model:

from mongothon import create_model

I get:

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/runpy.py", line 170, in _run_module_as_main
    "__main__", mod_spec)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "src/__main__.py", line 3, in <module>
    from database.mongodb.Collection import Collection
  File "src/database/mongodb/Collection.py", line 1, in <module>
    from mongothon import create_model
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/mongothon/__init__.py", line 3, in <module>
    from document import Document
ImportError: No module named 'document'

Any ideas?

Traits

Would be useful to be able to declare traits like in monufacture for commonly used items like timestamps, versioning fields etc.

Need to thing how this might work with virtual fields etc.

Make subdocument nodes independently validatable

Subnodes in documents have associated sub-schemas, so why not make them validatable?

This would go a long way to making atomic updates less scary as a frequent requirement is to add a subnode to an embedded array. Being able to validate that subnode prior to the atomic update would be useful.

Dirty tracking

Document should track the dirty state of fields. Here's a sketch of the idea:

    user = User.find_by_id(uid)
    user['first_name'] = 'bob'
    user['email'] = '[email protected]'
    user['referrers'].append('[email protected]')
    user['prefs']['alerts'] = True

    user.changed('first_name')      # => True
    user.changed()                  # => {'first_name', 'email'}
    user.changes                    # => {'first_name': ('robert', 'bob'), 'email': ('[email protected]', '[email protected]')}
    user.change('first_name')       # => ('robert', 'bob')
    user.was('first_name')          # => 'robert'

    user['prefs'].changed('alerts') # => True

    user['referrers'].added         # => ['[email protected]']
    user['referrers'].removed       # => []

    user.save()

    user.changed()                  # => []
    user.previous.changes           # => {'first_name': ('robert', 'bob'), 'email': ('[email protected]', '[email protected]')}
    user.previous.changed()         # => {'first_name', 'email'}

Virtual fields

Mongothon used to have virtual fields, and they sucked, mainly because they were part of the model.

Instead, we should extend Schema to allow virtual fields to be declared with the model's schema and be accessible as a dictionary accessor.

Sketch

# Create a schema
user_schema = Schema({
    'first_name': {'type': unicode, 'required': True},
    'last_name': {'type': unicode, 'required': True},
})

# Register virtual field getter
@user_schema.get('display_name')
def display_name(doc):
    return "{} {}".format(doc['first_name'], doc['last_name'])


# Consume virtual field
print user['display_name']

Document.__init__ doesn't allow keyword args

With the python dict constructor you can do:

d = dict({'foo': 'bar'}, baz='bat')
d == {'foo': 'bar', 'baz': 'bat'}

Document.__init__ currently only allows for a single (dictionary) argument. Should we change this?

Atomic operation builder DSL

Example:

BlogPost.update(id, atop.increment('likes').push(tags='cooking'))

Rather than...

BlogPost.update(id, {"$inc": {"likes": 1}, "$push": {"tags": "cooking"}})

Advantages:

  • Slightly better readability
  • "Compile-time" safety

Python3 support

It would be nice to Mongothon had python3 support.

Thanks!

Expose Schemer validators

To save needing to import schemer.validators, we should create a proxy at mongothon.validators, potentially adding Mongo-specific validators in future.

Rename Model.update

The update method on Model proxies to the underlying pymongo collection's update method. This is great, except it hides the update method on the underlying dict type.

We should rename it to something else so the dict version is still usable.

cc @byels

Make ScopeBuilder smarter

Right now ScopeBuilder requires an explicit call to execute() or a __getitem__ call to actually invoke the query. It should be a lot smarter:

  • Implement __iter__ forwarding to an underlying cursor, so we don't force Python to use the slow "try getting until we get an index error" method when iterating.
  • Forward any cursor methods to an underlying cursor
  • Eliminate the need for execute entirely. ScopeBuilder should function both as a builder and a proxy to the underlying query.

Query building DSL

What's needed is something similar to mongoose.js query building syntax.

Example:

Person.find(query.where('name.last').equals('Ghost')
                 .where('age').gt(17).lt(66)
                 .where('likes').in(['vaporizing', 'talking'])
                 .limit(10)
                 .sort('-occupation')
                 .select('name occupation'))

No License

Hi, thanks for your work on this project.

There is no license attached to the project, do which license do you intend to release this code under?

Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.