File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed
actions/devel/ferretdb/command Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change 19
19
import common .util as ut
20
20
import json
21
21
22
-
23
22
from pymongo import MongoClient
24
23
from common .command_data import CommandData
24
+ from bson import ObjectId
25
+
26
+ class JSONEncoder (json .JSONEncoder ):
27
+ def default (self , obj ):
28
+ if isinstance (obj , ObjectId ):
29
+ return str (obj ) # Convert ObjectId to string
30
+
31
+ return super ().default (obj )
25
32
26
33
class FerretDB ():
27
34
"""
@@ -56,8 +63,9 @@ def _send_command(self,input:CommandData):
56
63
db = self ._get_db ()
57
64
response = db .command (input .get_raw_data ())
58
65
59
- if response :
60
- input .result (str (response ))
66
+ if response :
67
+ json_output = json .dumps (response , cls = JSONEncoder , indent = 2 )
68
+ input .result (json_output )
61
69
input .status (200 )
62
70
else :
63
71
input .result (f"ferretdb/mongodb operation failed" )
You can’t perform that action at this time.
0 commit comments