# pymongo

PyMongo is a Python distribution and native driver providing synchronous and asynchronous APIs for working with MongoDB databases.

This is one page of public article previews, not the complete archive. Follow Next page to continue. Summaries are not the original full articles.

## Auto incrementing IDs for MongoDB

DevFeed: [Auto incrementing IDs for MongoDB](<https://devfeed.tech/articles/auto-incrementing-ids-for-mongodb-26283.md>)

Original publisher: [Read original article](<https://masnun.com/auto-incrementing-ids-for-mongodb/>)

Author: masnun

Published: 2018-12-06T17:14:35Z

Content type: tutorial

Language: en

Sources: [Abu Ashraf Masnun](<https://devfeed.tech/sources/abu-ashraf-masnun.md>)

Topics: [MongoDB](<https://devfeed.tech/topics/mongodb.md>), [pymongo](<https://devfeed.tech/topics/pymongo.md>), [Databases](<https://devfeed.tech/topics/databases.md>), [MySQL](<https://devfeed.tech/topics/mysql.md>), [PostgreSQL](<https://devfeed.tech/topics/postgresql.md>)

Tags: [code](<https://devfeed.tech/tags/code.md>), [deprecated](<https://devfeed.tech/tags/deprecated.md>), [general](<https://devfeed.tech/tags/general.md>), [mongodb](<https://devfeed.tech/tags/mongodb.md>), [mysql](<https://devfeed.tech/tags/mysql.md>), [nosql](<https://devfeed.tech/tags/nosql.md>), [operator](<https://devfeed.tech/tags/operator.md>), [postgresql](<https://devfeed.tech/tags/postgresql.md>), [pymongo](<https://devfeed.tech/tags/pymongo.md>), [python](<https://devfeed.tech/tags/python.md>), [relational-databases](<https://devfeed.tech/tags/relational-databases.md>)

### AI overview

This tutorial explains how to implement sequential, auto-incrementing IDs in MongoDB using a separate collection that stores the last used numeric ID. It describes atomically incrementing the value before inserting a document and notes that the older find-and-modify approach is deprecated.

### Source excerpt

If you're familiar with relational databases like MySQL or PostgreSQL, you're probably also familiar with auto incrementing IDs. You select a primary key for a table and make it auto incrementing. Every row you insert afterwards, each of them gets a new ID, automatically incremented from the last one. We don't have to keep track [...] The post Auto incrementing IDs for MongoDB appeared first on Abu Ashraf Masnun.