Skip to content

Commit

Permalink
changed id generation from uuid to ObjectId
Browse files Browse the repository at this point in the history
  • Loading branch information
theonlyamos committed Apr 11, 2024
1 parent 53b61bc commit 5361f7e
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 13 deletions.
2 changes: 1 addition & 1 deletion odbms/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

Database = None

VERSION = "0.2.8"
VERSION = "0.2.9"

def main(args):
global parser
Expand Down
8 changes: 1 addition & 7 deletions odbms/examples/user.py
Original file line number Diff line number Diff line change
@@ -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'''
Expand Down
7 changes: 3 additions & 4 deletions odbms/model.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from datetime import datetime
from typing import Union
import uuid

from bson.objectid import ObjectId
from .dbms import DBMS
Expand All @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -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()
Expand Down

0 comments on commit 5361f7e

Please sign in to comment.