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

Method get_next_value

mongoengine/fields.py:2147–2161  ·  view source on GitHub ↗

Helper method to get the next value for previewing. .. warning:: There is no guarantee this will be the next value as it is only fixed on set.

(self)

Source from the content-addressed store, hash-verified

2145 return self.value_decorator(counter["next"])
2146
2147 def get_next_value(self):
2148 """Helper method to get the next value for previewing.
2149
2150 .. warning:: There is no guarantee this will be the next value
2151 as it is only fixed on set.
2152 """
2153 sequence_name = self.get_sequence_name()
2154 sequence_id = f"{sequence_name}.{self.name}"
2155 collection = get_db(alias=self.db_alias)[self.collection_name]
2156 data = collection.find_one({"_id": sequence_id})
2157
2158 if data:
2159 return self.value_decorator(data["next"] + 1)
2160
2161 return self.value_decorator(1)
2162
2163 def get_sequence_name(self):
2164 if self.sequence_name:

Callers 1

Calls 2

get_sequence_nameMethod · 0.95
get_dbFunction · 0.90

Tested by 1