Liatz
Liatz

Reputation: 5207

mongodb schema data type for a list of numbers (or an array of numbers without a specific size)

what kind of schema data type should i use to define a list of numbers (or an array of numbers with changing size) I tried :

{type : [Number]}

but i suspect it may cause problems as i try to insert a value to the array (with $addToSet) from nodejs nothing happens,although trying to do this from mongodb interactive shell works fine.. perhaps(most likely) it's a different problem but i would like to remove any doubts regarding the way i defined the schema.

Thank you.

Upvotes: 1

Views: 2314

Answers (1)

StevenLooman
StevenLooman

Reputation: 381

Try this:

fieldName: [ { type: Number } ]

Upvotes: 2

Related Questions