0

How do I index an array element in mongoose, this is what i am trying in my schema, but its not working

locations : [{ 
    loc: { type: [Number], index: '2d'}
 }]
1
  • That looks ok. What's not working about it? Commented Apr 30, 2013 at 12:27

1 Answer 1

2

[Number] means array of numbers.... If want an array with out define the type you can use Mixed type like this :

loc: { type: [], index: '2d'}

Or

loc: { type: Schema.Types.Mixed, index: '2d'}

And by the way this is a documentation for mongoose schema types

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.