Exemple #1
0
class Access(object):
    def __init__(self):
        self.db = Database()

        self.collection_name = 'access'

        self.fields = {
            "role": "string",
            "ability": "string",
            "type": "string",
            "amount": "string",
            "status": "string",
            "created": "datetime",
            "updated": "datetime",
        }

    def create(self, access):
        res = self.db.insert(access, self.collection_name)
        return "Inserted Id " + res

    def find(self):
        return self.db.find(self.collection_name)

    def find_by_id(self, id):
        return self.db.find_by_id(id, self.collection_name)

    def update(self, id, access):
        return self.db.update(id, access, self.collection_name)

    def delete(self, id):
        return self.db.delete(id, self.collection_name)
Exemple #2
0
class Awards(object):
    def __init__(self):
        self.db = Database()

        self.collection_name = 'awards'

        self.fields = {
            "beginDate": "string",
            "endDate": "string",
            "condition": "string",
            "amount": "string",
            "type": "string",
            "created": "datetime",
            "updated": "datetime",
        }

    def create(self, awards):
        res = self.db.insert(awards, self.collection_name)
        return "Inserted Id " + res

    def find(self):
        return self.db.find(self.collection_name)

    def find_by_id(self, id):
        return self.db.find_by_id(id, self.collection_name)

    def update(self, id, awards):
        return self.db.update(id, awards, self.collection_name)

    def delete(self, id):
        return self.db.delete(id, self.collection_name)
Exemple #3
0
class Customer(object):
    def __init__(self):
        self.db = Database()

        self.collection_name = 'customer'

        self.fields = {
            "name": "string",
            "created": "datetime",
            "updated": "datetime",
            "wallets":[]
        }

    def create(self, customer):
        res = self.db.insert(customer, self.collection_name)
        return "Inserted Id " + res

    def find(self):
        return self.db.find(self.collection_name)

    def find_by_id(self, id):
        return self.db.find_by_id(id, self.collection_name)

    def update(self, id, customer):
        return self.db.update(id, customer, self.collection_name)

    def delete(self, id):
        return self.db.delete(id, self.collection_name)
Exemple #4
0
    def __init__(self):
        self.db = Database()

        self.collection_name = 'customer'

        self.fields = {
            "name": "string",
            "created": "datetime",
            "updated": "datetime",
            "wallets":[]
        }
Exemple #5
0
    def __init__(self):
        self.db = Database()

        self.collection_name = 'staff'

        self.fields = {
            "name": "string",
            "role": "string",
            "status": "string",
            "created": "datetime",
            "updated": "datetime",
        }
Exemple #6
0
    def __init__(self):
        self.db = Database()

        self.collection_name = 'wallet'

        self.fields = {
            "customerID": "string",
            "VIP": "string",
            "balance": "string",
            "status": "string",
            "created": "datetime",
            "updated": "datetime",
        }
Exemple #7
0
    def __init__(self):
        self.db = Database()

        self.collection_name = 'awards'

        self.fields = {
            "beginDate": "string",
            "endDate": "string",
            "condition": "string",
            "amount": "string",
            "type": "string",
            "created": "datetime",
            "updated": "datetime",
        }
Exemple #8
0
    def __init__(self):
        self.db = Database()

        self.collection_name = 'access'

        self.fields = {
            "role": "string",
            "ability": "string",
            "type": "string",
            "amount": "string",
            "status": "string",
            "created": "datetime",
            "updated": "datetime",
        }
class Todo(object):
    def __init__(self):
        self.validator = Validator()
        self.db = Database()

        self.collection_name = 'collection_name'

        self.fields = {
            "title": "string",
            "body": "string",
	    "created": "datetime"		
        }

        self.create_required_fields = ["title", "body"]

        # Fields optional for CREATE
        self.create_optional_fields = []

        # Fields required for UPDATE
        self.update_required_fields = []

        # Fields optional for UPDATE
        self.update_optional_fields = []

    def create(self, todo):
        # Validator will throw error if invalid
        self.validator.validate(todo, self.fields, self.create_required_fields, self.create_optional_fields)
        res = self.db.insert(todo, self.collection_name)
        return "Inserted Id " + res
Exemple #10
0
class Staff(object):
    def __init__(self):
        self.db = Database()

        self.collection_name = 'staff'

        self.fields = {
            "name": "string",
            "role": "string",
            "status": "string",
            "created": "datetime",
            "updated": "datetime",
        }

    def create(self, staff):
        res = self.db.insert(staff, self.collection_name)
        return "Inserted Id " + res

    def find(self):
        return self.db.find(self.collection_name)

    def find_by_id(self, id):
        return self.db.find_by_id(id, self.collection_name)

    def update(self, id, staff):
        return self.db.update(id, staff, self.collection_name)

    def delete(self, id):
        return self.db.delete(id, self.collection_name)

    def find_by_id_name(self, id, name):
        return self.db.find_by_id_name(id, name, self.collection_name)
Exemple #11
0
class Wallet(object):
    def __init__(self):
        self.db = Database()

        self.collection_name = 'wallet'

        self.fields = {
            "customerID": "string",
            "VIP": "string",
            "balance": "string",
            "status": "string",
            "created": "datetime",
            "updated": "datetime",
        }

    def create(self, wallet):
        res = self.db.insert(wallet, self.collection_name)
        return "Inserted Id " + res

    def find(self):
        return self.db.find(self.collection_name)

    def find_by_id(self, id):
        return self.db.find_by_id(id, self.collection_name)

    def update(self, id, wallet):
        return self.db.update(id, wallet, self.collection_name)

    def delete(self, id):
        return self.db.delete(id, self.collection_name)

    def find_by_customer_id(self, id):
        return self.db.find_by_customer_id(id, self.collection_name)
    def __init__(self):
        self.validator = Validator()
        self.db = Database()

        self.collection_name = 'collection_name'

        self.fields = {
            "title": "string",
            "body": "string",
	    "created": "datetime"		
        }

        self.create_required_fields = ["title", "body"]

        # Fields optional for CREATE
        self.create_optional_fields = []

        # Fields required for UPDATE
        self.update_required_fields = []

        # Fields optional for UPDATE
        self.update_optional_fields = []