Friday, 28 April 2017

Mongoose schema , how to define an Array of Array object

Is the following Mongoose schema correct ?

const TableSchema = new mongoose.Schema({
  meta: {... },
  columns: [{...}],
  lines: [[Schema.Types.Mixed]]
});

using the following table

  let table1 = {
    meta: { ... },
    columns: [ { ... }, { ... } ],
    lines: [[12, 'Joe'], [14, 'John'], [6, 'Walter'], [3, 'William'], [18, 'Bill'], [22, 'Albert']]
  };

when I get and display the table, the lines array is empty :

table:  { 
_id: 5903113e80587e09bf39be34,
  __v: 0,
  lines: [],
  columns: 
   [ { _id: 5903113e80587e09bf39be36, ... },
     { _id: 5903113e80587e09bf39be35, ... } ],
  meta: 
   { name: 'TA-PRIV-123', ... }
}



via erwin

No comments:

Post a Comment