0

I am looking for a way to shorten the ObjectID generated by the MongoDB and use it on Flask Blueprint.

I has googling and got this tutorial for shorten ObjectID using base64 http://flask.pocoo.org/snippets/106/

But, base64 is too long for me. So, i wanted better way to shorten ObjectID beside using base64. Thanks in advance!

adierebel
  • 11
  • 2
  • How long is too long? – kiecodes Feb 02 '17 at 11:59
  • @Kie base64 give me 16 characters, i want 6-8 chars for my url. – adierebel Feb 02 '17 at 12:02
  • Base128 might be possible? – kiecodes Feb 02 '17 at 12:40
  • Do you have a specific requirement to use ObjectIDs? The `_id` field is a required primary key, but you can provide your own values if you do not want a default ObjectID generated. The ObjectID formula was designed for distributed deployments where multiple clients need to independently generate unique identifiers with an extremely low chance of collision. You may be able to find a more concise algorithm to fit your use case. For example, if there is a low chance of concurrent document generation you could consider using a timestamp with second or millisecond precision. – Stennie Feb 03 '17 at 06:13

0 Answers0