Array with a single, unnamed field #414
Replies: 2 comments 2 replies
-
This is smart, I can immediatly see the use case here. I'm in support of implementing an added configuration options for One cautionary note about using this proposed configuration, is that once documents are made using the single Thanks for this @oranoran, we can see how it fits in with other work and if anyone is feeling inspired to submit a PR that would be hugely appreciated! |
Beta Was this translation helpful? Give feedback.
-
What's the status of this topic now? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Say we want to define a field which is a simple array of numbers. Simply
[1, 2]
.Today, we can try to do this through declaring an
array
field. But thefields
attribute ofarray
requires us to define named fields for the array's object type. So we end up with an array def that looks like thisfields: [{name: 'num', type: 'number'}]
.We therefore end up with something different than what we wanted, since now:
[{num: 1}, {num: 2}]
, instead of just[1,2]
What if as an alternative to the
fields
property we could define afield
property, containing a field definition, but withoutname
orlabel
properties. The definition for the array we want would now befield: {type: 'number'}
.Under this new definition:
[1, 2]
as intended.Note: The actual problem described here can also be addressed by adding a
hasMany
property to thenumber
field, and probably also totext
. This may actually be a good idea regardless of this discussion. But the proposed solution works also for complex types, which is cool!Beta Was this translation helpful? Give feedback.
All reactions