How can I create the array of strings in Keystone.js Database ODM?
Asked Answered
R

1

7

How can I create the array of strings in Keystone.js Database ODM? I have to create new model with single field and make a many:true relationship with him only?

Rosenkranz answered 20/3, 2014 at 13:45 Comment(2)
possible duplicate of How to add virtual property of type Array using Keystone.js?Rosenkranz
Some documentation about the solution of this (Types.TextArray) is avalable on Github github.com/keystonejs/keystone/tree/master/fields/types/…Sandblast
R
20

There is a field type for this:

Things.add({
  manyStrings: { type: Types.TextArray }
});

There is a similar field for numbers called Types.NumberArray.

If you want something more sophisticated, your best bet is creating a separate List and using the Relationship field.

Rebuff answered 11/1, 2015 at 13:23 Comment(5)
Can we use array of other types? like Types.NumberArrayImpetrate
How come the documentation doesn't mention Types.TextArray?Kunz
@JedWatson the lack of documentation is killer!Bim
+1 @Kunz Docs could be much better. Check project/node_modules/keystone/fields/types to see all types.Shirr
@Kunz At the time of your comment, the TextArrays are not in the current old-but-stable v0.3.x documentation, while the Array types are of the v4.0.0-beta.4 or beta 5. There is already some documentation about this on Github only github.com/keystonejs/keystone/tree/master/fields/types/…Sandblast

© 2022 - 2024 — McMap. All rights reserved.