

@classmethod
def insert(klass, to_insert):
    '\n        Insert a model into the database (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            MyTestModel.insert(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
    if DATABASE:
        if BACKEND_COLLECTION:
            this_collection = BACKEND_COLLECTION(DATABASE, klass)
            self.validate()
            ret_obj = to_insert.insert(to_insert)
            return ret_obj

dataset/ETHPy150Open lonelycode/Mojo/Mojo/ObjectMapper/ModelPrototype.py Model.insert/VarMisuse@55/240 `this_collection`->`to_insert`