Commit 67fa4b13 authored by Ahmad Anvari's avatar Ahmad Anvari

Add order class

parent b260177b
...@@ -2,19 +2,25 @@ from db.mongo import Model ...@@ -2,19 +2,25 @@ from db.mongo import Model
class Order(Model): class Order(Model):
def __init__(self): def __init__(self, user_id, product_id):
pass self.__id = None
self.__user_id = user_id
self.__product_id = product_id
def store(self): def store(self):
pass res = Order.get_collection().insert_one(self.to_dict())
return res.inserted_id
@staticmethod @staticmethod
def get_collection(): def get_collection():
pass return Model.get_db().get_collection("orders")
@staticmethod @staticmethod
def dict_to_object(dictionary): def dict_to_object(dictionary):
pass pass
def to_dict(self): def to_dict(self):
pass return {
"user_id": self.__user_id,
"product_id": self.__product_id
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment