Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8199807
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T06:14:49+00:00 2026-06-07T06:14:49+00:00

In the collection I’m working on, a document looks like this: { name: ‘Myname’,

  • 0

In the collection I’m working on, a document looks like this:

{
    name: 'Myname',
    other: 'other',
    stuff: [
        ['something', 12, 4, 'somethingelse'],
        ['morestuff', 2, 4, 8],
        ['finally', 12, 'again', 58],

    ]
}

I wrote this Mongoose schema to access it:

var MyDocSchema = new Schema({
    name: String,
    other: String,
    stuff: [],
});

When I query a doc, everything works well, the output shown in the console is right. But when, I try to do console.log(myDoc.stuff), I got the following:

['something', 12, 4, 'somethingelse', 'morestuff', 2, 4, 8, 'finally', 12, 'again', 58]

instead of

[
    ['something', 12, 4, 'somethingelse'],
    ['morestuff', 2, 4, 8],
    ['finally', 12, 'again', 58],

]

What am I doing wrong? Thank you for your help!!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T06:14:49+00:00Added an answer on June 7, 2026 at 6:14 am

    Disclaimer: This response is pretty dated, 2012! It might not be the most accurate.

    From the Mongoose documentation.

    http://mongoosejs.com/docs/schematypes.html: Scroll down to the Array section:

    Note: specifying an empty array is equivalent to [Mixed]. The
    following all create arrays of Mixed.

    Details on what that means is in the Mixed section right above the Array section.

    Here’s what you need to do.

    Define a schema for the embedded documents:

    var Stuff = new Schema({
      name: String,
      value1: Number,
      ...
    });
    

    Use that instead of an empty array []:

    var MyDocSchema = new Schema({
      name: String,
      other: String,
      stuff: [Stuff],
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My collection looks like this I need to get all those order no's whose
Garbage Collection can become a time consuming process. In this regard, the GC tends
I have a collection with nested documents in it. Each document also has an
I have a collection of type Collection<Lookup<int>> and I would like to convert its
Imagine a Model/Collection like: var AModel = Backbone.Model.extend({ defaults: { a: 'a string', b:
I have a Collection of items that I would like to display the Total
Given a document collection in Text::DocumentCollection in Perl, I want to calculate the cosine
Consider the collection List<Person> people = new List<Person> { new Person{Name = A, SSN=1,
I'm wondering what collection I should use for this purpose: Requirements Must contain tuples
Collection CollectionFactory::createFromMap(const std::string& name, const DataMap& dm) const { if (!Collection::isNameValid(name)) { const std::string

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.