Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I am new to MongoDB and python. I know how to make basic use of pymongo in order to manipulate documents.

I am having trouble finding how to create some structure or governance in what gets inside of the database.

Currently, I am storing with a dict {number:'',data:''}. Recently I wanted to change data to reg_id. I missed the change in one place, and that didnt came up until testing. It seems quite horrible that I would have to find every single place that I am accessing the data, and then change the key value of a map. Surely there must be a way or convention that is being used which works for large applications, right?

In my 700 line application it took 2 minutes to change the keys. In a 70k+ line application it would take hours to change all of them. So it seems like I'm doing something wrong.

To summarize my question:
Is using a plain dictionary the correct way of interacting with mongodb?
Or am I supposed to be using a domain-like-class to encapsulate the information I am currently putting in the dictionary?

share|improve this question
    
It's essentially not a whole lot different from traditional RDBMS; if you reference database columns directly from a variety of different places in your source, you have to refactor all these places independently. The design pattern here is to have only one canonical place where those columns are referenced and abstract everything else around it using classes or canonical getters/setters. –  deceze Mar 15 at 17:51

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.