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

Method set_next_value

mongoengine/fields.py:2134–2145  ·  view source on GitHub ↗

Helper method to set the next sequence value

(self, value)

Source from the content-addressed store, hash-verified

2132 return self.value_decorator(counter["next"])
2133
2134 def set_next_value(self, value):
2135 """Helper method to set the next sequence value"""
2136 sequence_name = self.get_sequence_name()
2137 sequence_id = f"{sequence_name}.{self.name}"
2138 collection = get_db(alias=self.db_alias)[self.collection_name]
2139 counter = collection.find_one_and_update(
2140 filter={"_id": sequence_id},
2141 update={"$set": {"next": value}},
2142 return_document=ReturnDocument.AFTER,
2143 upsert=True,
2144 )
2145 return self.value_decorator(counter["next"])
2146
2147 def get_next_value(self):
2148 """Helper method to get the next value for previewing.

Callers 4

setUpMethod · 0.80
test_sequence_fieldMethod · 0.80

Calls 2

get_sequence_nameMethod · 0.95
get_dbFunction · 0.90

Tested by 4

setUpMethod · 0.64
test_sequence_fieldMethod · 0.64