utils¶
Utility functions for the queries
module.
update_query(query, field, value, operator=None, **mongo_kwargs)
async
¶
Update a query's field
attribute with value
.
If field
is a dot-separated value, then only the last field part may be a
non-pre-existing field. Otherwise a KeyError
or AttributeError
will be raised.
Note
This can only update a field for a query's attributes
, i.e., this function
cannot update id
, type
or any other top-level resource field.
Important
mongo_kwargs
will not be considered for updating the pydantic model instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
query
|
QueryResource
|
The query to be updated. |
required |
field
|
str
|
The Example: |
required |
value
|
Any
|
The (possibly) new value for |
required |
operator
|
str | None
|
A MongoDB operator to be used for updating |
None
|
**mongo_kwargs
|
Any
|
Further MongoDB update filters. |
{}
|
Source code in optimade_gateway/queries/utils.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
|