Giter Site home page Giter Site logo

Comments (7)

rochacbruno avatar rochacbruno commented on May 8, 2024

Use factoryboy for it.

https://github.com/rbarrois/factory_boy

http://stackoverflow.com/questions/14346177/how-do-you-use-factory-boy-to-model-a-mongoengine-embeddeddocument

from quokka.

mauricioabreu avatar mauricioabreu commented on May 8, 2024

In my honest opinion, better than use a external tool, we can take advantage of mongoimport[1].
With mongoimport (which comes with MongoDB facilities) we can just issue a command to import a json file to the database since it is just sample data.


1: http://docs.mongodb.org/manual/reference/program/mongoimport/

from quokka.

rochacbruno avatar rochacbruno commented on May 8, 2024

👍

Do you how to implement it? so I think we just need to create the source files matching Quokka's database model. (is there a mongoexport tool? to generate raw Json from the current database?)

Also, we will need to write up a tutorial in a wiki page or maybe create a script to run it from manage.py populate

from quokka.

rochacbruno avatar rochacbruno commented on May 8, 2024

amazing! http://docs.mongodb.org/manual/reference/program/mongoexport/

from quokka.

mauricioabreu avatar mauricioabreu commented on May 8, 2024

Yes and it is mongoexport that you described above.
mongoexport exports collection so I think I should iterate over all models which create collections and issue the command mongoexport using the same approach with mongoimport. "show collections" MongoDB command could do the job as well.

from quokka.

mauricioabreu avatar mauricioabreu commented on May 8, 2024

So, I have worked in this approach:
https://gist.github.com/mauricioabreu/6590333 (code is not finished, but you get the idea)

But it is going wrong for several reasons.

Let's describe them one by one:

1 - It is hard to maintain since mongoexport has no limit (actually it is comming soon, but nowadays it is not even an option). to achieve success on this it would require a workaround to generate low amount of records.

2 - It is based of files, so a lot of things can happen like (wrong file, corrupted file, no permissions, etc)

3 - It is hard to check if a class creates a physical collection (this is why I am checking if it is a subclass of DynamicDocument and Document from mongoengine)

I think factory boy is a better approach in this case.

from quokka.

rochacbruno avatar rochacbruno commented on May 8, 2024

Thanks to @abnerpc there is now a populate from json file. I think there is no need to use mongodump for this feature.

from quokka.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.