suweller / mongoid-autoinc

⬆ Auto incrementing fields for Mongoid documents
MIT License
62 stars 44 forks source link

Question: There is a way to access AutoIncrementCounter? #42

Open niightly opened 4 months ago

niightly commented 4 months ago

Hello there, sorry to bother you with this, but I can't figure this out, do you know if there is a way to access this model via console, like: AutoIncrementCounter.all?

I need to update all the counters to a new ID, but I can't find a way to do it using db migrations. I really appreciate any help you can provide.

suweller commented 3 months ago

The counters are stored in a collection of their own. In theory you should be able to access this directly. Since this is not its original intended use, there's no interface exposed to reach directly into this collection. I'm curious if you are able to make it work, and would love to see how you ended up doing it 🙏 https://github.com/suweller/mongoid-autoinc/blob/30cfe694da15ddfa2709249fdfdd5d22b93e63c1/lib/autoinc/incrementor.rb#L37