Skip to content
This repository was archived by the owner on Aug 16, 2021. It is now read-only.

Commit ba3d192

Browse files
Fixed readme and others
1 parent 368f0f7 commit ba3d192

File tree

3 files changed

+11
-23
lines changed

3 files changed

+11
-23
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ db.set('foo', 'bar') # Will set value 'bar' for the key 'foo'
7070
db.get('foo') # Will return 'bar' which is the value of the key 'foo'
7171

7272
db.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

7575
db.delete('foo') # Will delete value of the key 'foo'
7676
db.delete_all() # Will delete all values of the all keys! Simple drop() function

quickmongo/Util.py

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,15 @@
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
2415
def add(a: int, b:int):

quickmongo/__init__.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,10 @@
1919
from typing import Any
2020

2121
# Import files
22-
from .Util import *
22+
from .Util import startswith
2323
from .Base import Base
2424
from .Exception import *
2525

26-
# Make the util class ready
27-
util = Util()
28-
2926
# Database Class which is the main class
3027
class 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:

0 commit comments

Comments
 (0)