javascript - Does order of schema matter in Node.JS? -


im make huge schema form have built... being said schema order have mimic form order, or can have inputs in order put them in ? example below. can this?

// link mongoose var mongoose = require('mongoose');  // define article schema var mapschema = new mongoose.schema({ created: {    type: date,    default: date.now }, dd1: {     type: string,     default: '' }, dd2: {     type: string,     default: '' }, com1: {     type: string,     default: '' }, com2: {     type: string,     default: '' } });  // make public module.exports = mongoose.model('map', mapschema); 

or have this?

// link mongoose var mongoose = require('mongoose');  // define article schema var mapschema = new mongoose.schema({  created: {    type: date,    default: date.now }, dd1: {     type: string,     default: '' }, com1: {     type: string,     default: '' },  dd2: {     type: string,     default: '' }, com2: {     type: string,     default: '' } });  // make public module.exports = mongoose.model('map', mapschema); 

does schema order have mimic form order, or can have inputs in order put them in?

mongoose.schema accepts javascript object parameter. question boils down to:

are javascript objects aware of order keys defined in?

the answer is: no, key order not maintained in javascript objects. js spec explicitly states objects unordered key/value collections. (compare)

therefore follows mongoose.schema not rely on key order if tied to, means free order keys in way like.


we can tackle question other end:

is front-end change form field order forces me rewrite database backend code?

and answer is: no, pretty darn unlikely. can dismiss thought without looking kind of spec, because not make kind of sense.


Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -