MCPcopy Index your code
hub / github.com/MongoEngine/mongoengine / _integrate_shard_key

Method _integrate_shard_key

mongoengine/document.py:534–549  ·  view source on GitHub ↗

Integrates the collection's shard key to the `select_dict`, which will be used for the query. The value from the shard key is taken from the `doc` and finally the select_dict is returned.

(self, doc, select_dict)

Source from the content-addressed store, hash-verified

532 return update_doc
533
534 def _integrate_shard_key(self, doc, select_dict):
535 """Integrates the collection's shard key to the `select_dict`, which will be used for the query.
536 The value from the shard key is taken from the `doc` and finally the select_dict is returned.
537 """
538
539 # Need to add shard key to query, or you get an error
540 shard_key = self._meta.get("shard_key", tuple())
541 for k in shard_key:
542 path = self._lookup_field(k.split("."))
543 actual_key = [p.db_field for p in path]
544 val = doc
545 for ak in actual_key:
546 val = val[ak]
547 select_dict[".".join(actual_key)] = val
548
549 return select_dict
550
551 def _save_update(self, doc, save_condition, write_concern):
552 """Update an existing document.

Callers 2

_save_createMethod · 0.95
_save_updateMethod · 0.95

Calls 3

_lookup_fieldMethod · 0.80
joinMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected