Skip to content

Allow both object and array values for an argument (create/createMany) #360

Description

@davidcheung

continuing the conversation for this comment #347 (comment)

Since #347, strong-remoting rejects array values for arguments of type object. As a result, it's no longer possible to send an array of objects via POST /api/my-model-/create and expect the server to create them all in a batch mode.

Background

with https://github.com/strongloop/strong-remoting/blob/master/3.0-RELEASE-NOTES.md#conversion-and-coercion-of-input-arguments
Array values are not allowed for arguments of type object.
https://github.com/strongloop/loopback/blob/ed8b651b988799b5b42289bddd9f568398776bc8/lib/persisted-model.js#L643

Why its a problem

I think the biggest breaking change brought from this would be the ability to do batch POST operations

Possible options

  • Option 1
    [SEMVER-MAJOR] Fix object type conversion #347 (comment)
    add flag to allowArrays for object coercion
    i would go with this as it's least painful for migration
  • Option 2
    change type of persistetedModel methods that supports batch operations to 'any'
  • Option 3
    Create POST /createMany and take array of objects

@strongloop/loopback-dev

Metadata

Metadata

Assignees

Labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions