From 5361f7ea178b4bbc9eb2ad186dd5384ac78f611b Mon Sep 17 00:00:00 2001 From: theonlyamos Date: Thu, 11 Apr 2024 18:54:21 +0000 Subject: [PATCH] changed id generation from uuid to ObjectId --- odbms/app.py | 2 +- odbms/examples/user.py | 8 +------- odbms/model.py | 7 +++---- setup.py | 2 +- 4 files changed, 6 insertions(+), 13 deletions(-) diff --git a/odbms/app.py b/odbms/app.py index e5de5bc..d57963d 100644 --- a/odbms/app.py +++ b/odbms/app.py @@ -5,7 +5,7 @@ Database = None -VERSION = "0.2.8" +VERSION = "0.2.9" def main(args): global parser diff --git a/odbms/examples/user.py b/odbms/examples/user.py index 559e093..3fbcf65 100644 --- a/odbms/examples/user.py +++ b/odbms/examples/user.py @@ -1,11 +1,5 @@ -from datetime import datetime -from typing import Dict, List -import uuid - -from bson.objectid import ObjectId - from odbms import DBMS, Model - +from utils import Utils class User(Model): '''A model class for user''' diff --git a/odbms/model.py b/odbms/model.py index d031420..061b207 100644 --- a/odbms/model.py +++ b/odbms/model.py @@ -1,6 +1,5 @@ from datetime import datetime from typing import Union -import uuid from bson.objectid import ObjectId from .dbms import DBMS @@ -15,11 +14,11 @@ class Model(): LIMIT = 0 def __init__(self, created_at=None, updated_at=None, id=None): - self.created_at = (datetime.utcnow()).strftime("%a %b %d %Y %H:%M:%S") \ + self.created_at = (datetime.now()).strftime("%a %b %d %Y %H:%M:%S") \ if not created_at else created_at - self.updated_at = (datetime.utcnow()).strftime("%a %b %d %Y %H:%M:%S") \ + self.updated_at = (datetime.now()).strftime("%a %b %d %Y %H:%M:%S") \ if not updated_at else updated_at - self.id = str(uuid.uuid4()) if not id else str(id) + self.id = str(ObjectId()) if not id else str(id) @classmethod def create_table(cls): diff --git a/setup.py b/setup.py index 1f564ec..0533ee4 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,7 @@ from importlib.metadata import entry_points from setuptools import setup, find_packages -VERSION = '0.2.8' +VERSION = '0.2.9' with open('README.md', 'rt') as file: description = file.read()