

@classmethod
@gen.engine
def insert_async(klass, to_insert, *args, **kwargs):
    '\n        Insert a model into the database (non-blocking).\n\n        **Usage:** ::\n\n            from models import MyTestModel\n\n            my_data = {\n                    \'this_field\':       "Hello World",\n                    \'another_field\':    42,\n                    \'whatever_field\':   True\n                  }\n\n            yield gen.Task(MyTestModel.insert_async, MyTestModel(my_data))\n\n        This will validate the fields before committing them to the database, without having to instantiate a new\n        model instance.\n\n        '
    from Mojo.ServerHelpers.RunServer import BACKEND_COLLECTION, DATABASE
    cb = kwargs['callback']
    del kwargs['callback']
    if DATABASE:
        if BACKEND_COLLECTION:
            this_collection = BACKEND_COLLECTION(DATABASE, klass)
            ret_obj = (yield gen.Task(this_collection.insert, to_insert, *args, **kwargs))
            cb(ret_obj)

dataset/ETHPy150Open lonelycode/Mojo/Mojo/ObjectMapper/ModelPrototype.py Model.insert_async/original