# Path: demos/models/settings.py
# MONGO_DB_MAPPING = {
#     'db': {
#         'test': _test,
#         'user': _user,
#         'tag': _tag,
#     },
#     'db_file': {
#         'test': _test_files,
#         'user': _user_files,
#     }
# }
# 
# DB_ENGINE_MAPPING = {
#     'blog': blog_engine,
# }


from datetime import datetime
from bson.objectid import ObjectId
from pymongo import ASCENDING, DESCENDING
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker
from .settings import (
    MONGO_DB_MAPPING as _MONGO_DB_MAPPING,
    DB_ENGINE_MAPPING as _DB_ENGINE_MAPPING,
)
import time
import turbo.model
import turbo.util
import turbo_motor.model


# todo change name



class BaseModel(turbo.model.BaseModel):

    package_space = globals()

    def __init__(self, db_name='test'):
        super(BaseModel, self).__init__(db_name, _MONGO_DB_MAPPING)

    def get_count(self, spec=None):
        return self.find(spec=spec).count()


class SqlBaseModel(object):

    def __init__(self, db_name='test'):
        engine = _DB_ENGINE_MAPPING[db_name]
        self.Base = declarative_base(bind=engine)
        self.Session = self.create_session(engine)

    def create_session(self, engine):
        return sessionmaker(bind=engine)


class MotorBaseModel(turbo_motor.model.BaseModel):


# Path: demos/models/settings.py
# MONGO_DB_MAPPING = {
#     'db': {
#         'test': _test,
#         'user': _user,
#         'tag': _tag,
#     },
#     'db_file': {
#         'test': _test_files,
#         'user': _user_files,
#     }
# }
# 
# DB_ENGINE_MAPPING = {
#     'blog': blog_engine,
# }


# Path: demos/models/base.py
from datetime import datetime
from bson.objectid import ObjectId
from pymongo import ASCENDING, DESCENDING
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker
from .settings import (
    MONGO_DB_MAPPING as _MONGO_DB_MAPPING,
    DB_ENGINE_MAPPING as _DB_ENGINE_MAPPING,
)
import time
import turbo.model
import turbo.util
import turbo_motor.model



# todo change name



class BaseModel(turbo.model.BaseModel):

    package_space = globals()

    def __init__(self, db_name='test'):
        super(BaseModel, self).__init__(db_name, _MONGO_DB_MAPPING)

    def get_count(self, spec=None):
        return self.find(spec=spec).count()


class SqlBaseModel(object):

    def __init__(self, db_name='test'):
        engine = _DB_ENGINE_MAPPING[db_name]
        self.Base = declarative_base(bind=engine)
        self.Session = self.create_session(engine)

    def create_session(self, engine):
        return sessionmaker(bind=engine)


class MotorBaseModel(turbo_motor.model.BaseModel):


    package_space = globals()