Bulk create partial failure
Review this Python bulk-create endpoint.
What a strong answer looks like
Separate real bugs from style. Rank issues by severity, point at the root cause rather than the symptom, and suggest a concrete fix, specific and kind.
0:00 of about 25 min
Mark a line and say what kind of problem it is.0 findings
1@app.route('/contacts/bulk', methods=['POST'])
2def bulk_create():
3 contacts = request.get_json() # list of objects
4 created = []
5 for c in contacts:
6 contact = Contact(email=c['email'], name=c['name'])
7 db.session.add(contact)
8 created.append(contact.id)
9 db.session.commit()
10 return jsonify({'created': created}), 201
Which questions mattered is sealed until you submit. Telling you now would just be handing over the edge cases.
Run or narrate your approach, then ask the coach.