We have a "MyModule" module, which has a mymodule.install. Inside the file, there is mymodule_update_8001, 8002 ... etc.
How can I tell programmatically that on which version the module has at the moment? I know where to find them in database (key_value table), but I would like to use a service instead, if that's possible.
The closest I found:
$update_hook_count = \Drupal::keyValue('system.schema')->get('mymodule');
This returns the update hook number.