Skip to content

Commit 67dd93b

Browse files
committed
Feature Added: Show Collection
1 parent a0395e5 commit 67dd93b

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

filexdb/database.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from .collection import Collection
44
from .fileio import BinaryFileIO, JsonFileIO
5-
5+
from .document import JsonArray
66

77
class FileXdb:
88

@@ -18,7 +18,7 @@ def __init__(self, db_name: str, data_dir=None, mode="binary"):
1818
:param db_name: Name of Database without file extension.
1919
:param data_dir: Where the Database will be stored.
2020
"""
21-
21+
self._database = {}
2222
self._db_name = db_name
2323
self._data_dir = data_dir
2424

@@ -42,9 +42,16 @@ def collection(self, col_name: str) -> Collection:
4242

4343
return collection
4444

45-
def show_collections(self):
46-
pass
45+
def show_collections(self) -> JsonArray:
46+
"""
47+
Shows all collections of database.
48+
:return: List Collections.
49+
"""
50+
self._database = self._file_handler.read()
4751

52+
# Initiating empty result list
53+
_result = JsonArray(list(self._database.keys()))
4854

55+
return _result
4956

5057

0 commit comments

Comments
 (0)