MCPcopy Create free account
hub / github.com/dot-agent/nextpy / query

Method query

nextpy/data/jsondb.py:204–222  ·  view source on GitHub ↗

Queries the database with the given parameters. Args: **kwargs: Field names and values for the query. Returns: List[T]: A list of instances that match the query.

(self, **kwargs)

Source from the content-addressed store, hash-verified

202 return instance
203
204 def query(self, **kwargs) -> List[T]:
205 """Queries the database with the given parameters.
206
207 Args:
208 **kwargs: Field names and values for the query.
209
210 Returns:
211 List[T]: A list of instances that match the query.
212 """
213 data = self._read_data()["data"]
214 if not kwargs:
215 return [self.model(**record) for record in data] # type: ignore
216
217 filtered_data = [
218 record
219 for record in data
220 if all(record.get(k) == v for k, v in kwargs.items())
221 ]
222 return [self.model(**record) for record in filtered_data] # type: ignore
223
224 def get(self, id_value: int) -> Optional[T]:
225 """Retrieves an instance from the database by its ID.

Callers 7

similarity_searchMethod · 0.45
similarity_searchMethod · 0.45
test_query_usersFunction · 0.45
get_productFunction · 0.45
list_productFunction · 0.45
update_productFunction · 0.45
delete_productFunction · 0.45

Calls 3

_read_dataMethod · 0.95
itemsMethod · 0.80
getMethod · 0.45

Tested by 1

test_query_usersFunction · 0.36