This repository was archived by the owner on Aug 16, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +11
-23
lines changed
Expand file tree Collapse file tree 3 files changed +11
-23
lines changed Original file line number Diff line number Diff line change @@ -70,7 +70,7 @@ db.set('foo', 'bar') # Will set value 'bar' for the key 'foo'
7070db.get(' foo' ) # Will return 'bar' which is the value of the key 'foo'
7171
7272db.all() # Will return all keys and values of the collection! {'key': 'foo', 'value': 'bar'} as a dict
73- db.startsWith (' f' ) # Will sort all data whose keys startswith 'f' as {'key': 'foo', 'value': 'bar'}
73+ db.startswith (' f' ) # Will sort all data whose keys startswith 'f' as {'key': 'foo', 'value': 'bar'}
7474
7575db.delete(' foo' ) # Will delete value of the key 'foo'
7676db.delete_all() # Will delete all values of the all keys! Simple drop() function
Original file line number Diff line number Diff line change 11# Util Class
22# Some functions which are different from Base
33
4- class Util ():
4+ # Filter for startswith()
5+ def startswith (self , data , query : str ):
6+ result = []
57
6- # Startswith filter
7- def startswith ( self , data , query : str ):
8- result = []
8+ for doc in data :
9+ if ( doc [ 'key' ]. startswith ( query ) ):
10+ result . append ( doc )
911
10- for doc in data :
11- if (doc ['key' ].startswith (query )):
12- result .append (doc )
13-
14- return result
15-
16- # Convert dict to attr
17- class AttrDict ():
18-
19- def __init__ (self , arg : dict ):
20- for key in arg .keys ():
21- setattr (self , key , arg [key ])
12+ return result
2213
2314# Math Functions
2415def add (a : int , b :int ):
Original file line number Diff line number Diff line change 1919from typing import Any
2020
2121# Import files
22- from .Util import *
22+ from .Util import startswith
2323from .Base import Base
2424from .Exception import *
2525
26- # Make the util class ready
27- util = Util ()
28-
2926# Database Class which is the main class
3027class Database ():
3128
@@ -82,8 +79,8 @@ def get(self, key: str) -> Any:
8279 def all (self ) -> list :
8380 return self .base .all ()
8481
85- def startsWith (self , query : str ) -> list :
86- return util . startswith (self .base .all (), query )
82+ def startswith (self , query : str ) -> list :
83+ return startswith (self .base .all (), query )
8784
8885 def math (self , key : str , symbol : str , amount : int ) -> None :
8986 if symbol not in math_symbols :
You can’t perform that action at this time.
0 commit comments