Create issue
Issue #25 new
Randall Degges created an issue

What do you guys think about adding a get_or_create method? I think this would be cool, similar to how Django's ORM ships with Model.objects.get_or_create().

I'm using this in some applications currently, might be a useful shortcut for other users as well.

What do you think?

Comments (1)

  1. Éric Araujo

    At Ludia we use DynamoDB in web applications that follow REST/ROA principles (Resource-Oriented Architecture as outlined in the book RESTful Web Services). In that model, we can’t create something lazily on a GET request for instance. In other words, we have clearly separate contexts where we get and where we create records.

    That said, I see in that the Django method “is meant as a shortcut to boilerplatish code and is mostly useful for data-import scripts”, so I agree there is a use case even for our kind of web apps. So one question: if this method only saves three lines, should it be in DDBM or just in the docs? And isn’t it already covered by Model(...).save(raise_on_conflict=False) ?

  2. Log in to comment