You are clear, but I think that there is a misunderstanding problem.

The order of elements in an array is important. In fact, each element in
the array is in the same order as you specified.

The order of properties in an object, on the other hand, is unspecified and
can change from one JavaScript implementation to the other. When talking
about objects and properties, the only important thing is that the same
properties (associations between a name and a value) are retained, even if
the relative order is changed.

This is what the others told you until now, I hope that another explanation
from a different guy helps you refreshing your mind.


2014-05-03 17:06 GMT+02:00 Alejandro Paciotti <[email protected]>
:

> Sory Angel, maybe I can not explain properly.
>
> The problem is with each elements in the *data *object  that are recorded
> in reverse order.
>
> [image: Imágenes integradas 1]
>
> I admit I conceptually confused with arrays and objects, but *data is an
> array* that contains *objects* of 7 elements.
>
> The problem is with the objects that are recorded invested.
>
> *Periodo, Total, CobradoSegunContrato..... Ultimas_Adelantadas*  becomes  
> *Ultimas_Adelantadas,
> Proximas_Adelantadas, Proyectado... Periodo.*
>
>  I hope I was more clear.
>
> Thanks again.
>
>
> [email protected]
>
>
> 2014-05-03 11:35 GMT-03:00 Angel Java Lopez <[email protected]>:
>
> I still don't understand
>>
>> The data object is in order, the first element is the original first
>> element. And the second element is still the second element. Or not?
>> According to your second email, the title of this thread "Order in array is
>> reversed when save in mongodb" is NOT the case.
>>
>> The array keeps the order.
>>
>> In which way the order of PROPERTIES of EACH element has influence on the
>> chart output?
>>
>> Angel "Java" Lopez
>> @ajlopez
>>
>>
>>
>> On Sat, May 3, 2014 at 11:30 AM, Alejandro Paciotti <
>> [email protected]> wrote:
>>
>>> The problem is that i use this object (*data*) for charts, where the
>>> order is very important.
>>>
>>> In the initial email i wrote without copy & paste, and i think that was
>>> a problem with the configuration, but not. Apparently is a v8 behavior.
>>>
>>> I do not understand yet.
>>>
>>> Thanks!
>>>
>>>
>>> [email protected]
>>>
>>>
>>> 2014-05-03 6:22 GMT-03:00 Angel Java Lopez <[email protected]>:
>>>
>>> Ummm... but what is the problem?
>>>>
>>>> You retrieved the array with the elements in the same order, that is,
>>>> the array is the same. The only difference, is that EACH element is an
>>>> object and the property order are mangled. But what is the problem for your
>>>> program?
>>>>
>>>> The initial email described another situation: mangled array. But
>>>> apparently, this is not the case.
>>>>
>>>> Angel "Java" Lopez
>>>> @ajlopez
>>>>
>>>>
>>>>
>>>> On Sat, May 3, 2014 at 3:28 AM, Alejandro Paciotti <
>>>> [email protected]> wrote:
>>>>
>>>>> I send to the function this:
>>>>>
>>>>> [ { Periodo: '2010-08',
>>>>>     Total: 1363371.31,
>>>>>     CobradoSegunContrato: 700741.61,
>>>>>     Cuota_Licitacion: 44565,
>>>>>     Proyectado: 812304.29,
>>>>>     Proximas_Adelantadas: 271622.7,
>>>>>     Ultimas_Adelantadas: 161692 },
>>>>>   { Periodo: '2010-09',
>>>>>     Total: 973838.09,
>>>>>     CobradoSegunContrato: 662753.06,
>>>>>     Cuota_Licitacion: 16241.92,
>>>>>     Proyectado: 514792.1,
>>>>>     Proximas_Adelantadas: 60626.61,
>>>>>     Ultimas_Adelantadas: 126851.5 }]
>>>>>
>>>>> I save like this:
>>>>>
>>>>> {
>>>>>     "name" : "ingresos",
>>>>>     "_id" : ObjectId("53648b1d1579089428dfb8ae"),
>>>>>     "data" : [
>>>>>         {
>>>>>             "Ultimas_Adelantadas" : 161692,
>>>>>             "Proximas_Adelantadas" : 271622.7,
>>>>>             "Proyectado" : 812304.29,
>>>>>             "Cuota_Licitacion" : 44565,
>>>>>             "CobradoSegunContrato" : 700741.61,
>>>>>             "Total" : 1363371.31,
>>>>>             "Periodo" : "2010-08"
>>>>>         },
>>>>>         {
>>>>>             "Ultimas_Adelantadas" : 126851.5,
>>>>>             "Proximas_Adelantadas" : 60626.61,
>>>>>             "Proyectado" : 514792.1,
>>>>>             "Cuota_Licitacion" : 16241.92,
>>>>>             "CobradoSegunContrato" : 662753.0600000001,
>>>>>             "Total" : 973838.09,
>>>>>             "Periodo" : "2010-09"
>>>>>         },
>>>>>
>>>>> etc.. etc..
>>>>>
>>>>> I don't understand.
>>>>>
>>>>> Thanks!
>>>>>
>>>>>
>>>>> [email protected]
>>>>>
>>>>>
>>>>> 2014-05-03 2:59 GMT-03:00 Jose Luis Rivas <[email protected]>:
>>>>>
>>>>> An Array is ['field1', 100, 200].
>>>>>>
>>>>>> Key-based is an Object.
>>>>>>
>>>>>> If you save an object, with {'field1': 100, 'field200': 200 } it will
>>>>>> be
>>>>>> saved lexicographically.
>>>>>>
>>>>>> Kind regards.
>>>>>>
>>>>>> On 5/2/14, 11:50 PM, Alejandro Paciotti wrote:
>>>>>> > Hi
>>>>>> >
>>>>>> > I have a function that save a document in a mongodb database:
>>>>>> >
>>>>>> > function *savedata*(name, data, next){
>>>>>> >
>>>>>> > var ResultsModel=mongoose.model('Result',
>>>>>> > { name:String,
>>>>>> >  create_at:{type:Date,default:Date.now},
>>>>>> >  *data:[]*
>>>>>> > });
>>>>>> >
>>>>>> > var r=new ResultsModel();
>>>>>> > r.name <http://r.name> = name;
>>>>>> > *r.data = data;*
>>>>>> > r.save(function(err){
>>>>>> > if(err) throw err;
>>>>>> > next();
>>>>>> > });
>>>>>> > }
>>>>>> >
>>>>>> >
>>>>>> > If i call a function with    savedata('reportname', *['field1': 100,
>>>>>> > 'field2': 200]*, function(err){ console.log('done') })
>>>>>> >
>>>>>> > When i want retreive the data, the array is like this: *['field2':
>>>>>> 200,
>>>>>> > 'field1': 100]* . Perfectly reversed.
>>>>>> >
>>>>>> > Any idea?
>>>>>> >
>>>>>> >
>>>>>> >
>>>>>> >
>>>>>> > [email protected] <mailto:[email protected]>
>>>>>> >
>>>>>> > --
>>>>>> > --
>>>>>> > Job Board: http://jobs.nodejs.org/
>>>>>> > Posting guidelines:
>>>>>> > https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
>>>>>> > You received this message because you are subscribed to the Google
>>>>>> > Groups "nodejs" group.
>>>>>> > To post to this group, send email to [email protected]
>>>>>> > To unsubscribe from this group, send email to
>>>>>> > [email protected]
>>>>>> > For more options, visit this group at
>>>>>> > http://groups.google.com/group/nodejs?hl=en?hl=en
>>>>>> >
>>>>>> > ---
>>>>>> > You received this message because you are subscribed to the Google
>>>>>> > Groups "nodejs" group.
>>>>>> > To unsubscribe from this group and stop receiving emails from it,
>>>>>> send
>>>>>> > an email to [email protected]
>>>>>> > <mailto:[email protected]>.
>>>>>> > For more options, visit https://groups.google.com/d/optout.
>>>>>>
>>>>>> --
>>>>>> Jose Luis Rivas - http://joseluisrivas.net
>>>>>> Venezuela - GPG: 0xB9AC8C43
>>>>>>
>>>>>> --
>>>>>> --
>>>>>> Job Board: http://jobs.nodejs.org/
>>>>>> Posting guidelines:
>>>>>> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
>>>>>> You received this message because you are subscribed to the Google
>>>>>> Groups "nodejs" group.
>>>>>> To post to this group, send email to [email protected]
>>>>>> To unsubscribe from this group, send email to
>>>>>> [email protected]
>>>>>> For more options, visit this group at
>>>>>> http://groups.google.com/group/nodejs?hl=en?hl=en
>>>>>>
>>>>>> ---
>>>>>> You received this message because you are subscribed to the Google
>>>>>> Groups "nodejs" group.
>>>>>> To unsubscribe from this group and stop receiving emails from it,
>>>>>> send an email to [email protected].
>>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>>
>>>>>
>>>>>  --
>>>>> --
>>>>> Job Board: http://jobs.nodejs.org/
>>>>> Posting guidelines:
>>>>> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups "nodejs" group.
>>>>> To post to this group, send email to [email protected]
>>>>> To unsubscribe from this group, send email to
>>>>> [email protected]
>>>>> For more options, visit this group at
>>>>> http://groups.google.com/group/nodejs?hl=en?hl=en
>>>>>
>>>>> ---
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups "nodejs" group.
>>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>>> an email to [email protected].
>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>
>>>>
>>>>  --
>>>> --
>>>> Job Board: http://jobs.nodejs.org/
>>>> Posting guidelines:
>>>> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
>>>> You received this message because you are subscribed to the Google
>>>> Groups "nodejs" group.
>>>> To post to this group, send email to [email protected]
>>>> To unsubscribe from this group, send email to
>>>> [email protected]
>>>> For more options, visit this group at
>>>> http://groups.google.com/group/nodejs?hl=en?hl=en
>>>>
>>>> ---
>>>> You received this message because you are subscribed to the Google
>>>> Groups "nodejs" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>> an email to [email protected].
>>>> For more options, visit https://groups.google.com/d/optout.
>>>>
>>>
>>>  --
>>> --
>>> Job Board: http://jobs.nodejs.org/
>>> Posting guidelines:
>>> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
>>> You received this message because you are subscribed to the Google
>>> Groups "nodejs" group.
>>> To post to this group, send email to [email protected]
>>> To unsubscribe from this group, send email to
>>> [email protected]
>>> For more options, visit this group at
>>> http://groups.google.com/group/nodejs?hl=en?hl=en
>>>
>>> ---
>>> You received this message because you are subscribed to the Google
>>> Groups "nodejs" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to [email protected].
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>  --
>> --
>> Job Board: http://jobs.nodejs.org/
>> Posting guidelines:
>> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
>> You received this message because you are subscribed to the Google
>> Groups "nodejs" group.
>> To post to this group, send email to [email protected]
>> To unsubscribe from this group, send email to
>> [email protected]
>> For more options, visit this group at
>> http://groups.google.com/group/nodejs?hl=en?hl=en
>>
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "nodejs" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>  --
> --
> Job Board: http://jobs.nodejs.org/
> Posting guidelines:
> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> You received this message because you are subscribed to the Google
> Groups "nodejs" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en
>
> ---
> You received this message because you are subscribed to the Google Groups
> "nodejs" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>

-- 
-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to