Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

api.py create/update list rather than one at a time #345

Open
tduval-unifylogic opened this issue Jun 10, 2021 · 0 comments
Open

api.py create/update list rather than one at a time #345

tduval-unifylogic opened this issue Jun 10, 2021 · 0 comments

Comments

@tduval-unifylogic
Copy link

tduval-unifylogic commented Jun 10, 2021

Greetings! Long time no chat. I am in the process of generating a service using OpenAlchemy and want to create the endpoint fulfillment a little differently. (api.py) and am wondering if you have any thoughts on how I might go about it? I will use your employee example to explain it.

For post: I would like to have a list of employees (one-or-more) rather than having one employee in the body.

For patch: same as post, update a list of employees (one-or-more), additionally, want to not have to hardcode the property names to the keys in the body dictionary. Since the model is a reflection of the API schema, this seems superflous to me? Can't it just be database.db.session.update(employees)?

Lastly, I am curious as to the performance of iterating db.Add (or db.Update) vs a way to persist employees in bulk ( SQLAlchemy bulk_save_objects, update_changed_only) like I can do with pandas (which smokes!).
I'm not a big fan of iterating.

I was thinking it might be a comprehension? An array of employees, like the one returned from get are passed in the def post(body) and then it would be something like:

  • database.db.session.bulk_save_objects(map(models.Employee.from_dict(), body))

The question I have is, how to represent in the openapi.yml file (post and schema) that the body contains array?

Thanks in advance!

Tim

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant