@stonyx/orm 0.2.5-alpha.0 → 0.2.7-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/orm-request.js +5 -5
package/package.json
CHANGED
package/src/orm-request.js
CHANGED
|
@@ -215,15 +215,15 @@ export default class OrmRequest extends Request {
|
|
|
215
215
|
},
|
|
216
216
|
|
|
217
217
|
post: {
|
|
218
|
-
[`/${pluralizedModel}`]: (
|
|
219
|
-
const { attributes } =
|
|
218
|
+
[`/${pluralizedModel}`]: ({ body, query }) => {
|
|
219
|
+
const { type, attributes } = body?.data || {};
|
|
220
220
|
|
|
221
|
-
if (!
|
|
221
|
+
if (!type) return 400; // Bad request
|
|
222
222
|
|
|
223
|
-
const fieldsMap = parseFields(
|
|
223
|
+
const fieldsMap = parseFields(query);
|
|
224
224
|
const modelFields = fieldsMap.get(pluralizedModel) || fieldsMap.get(model);
|
|
225
225
|
// Check for duplicate ID
|
|
226
|
-
if (attributes
|
|
226
|
+
if (attributes?.id !== undefined && store.get(model, attributes.id)) return 409; // Conflict
|
|
227
227
|
|
|
228
228
|
const record = createRecord(model, attributes, { serialize: false });
|
|
229
229
|
|