Is there a way to use numeric keys for objects with Mongoose? Such as:
有没有办法使用数字键与Mongoose对象?如:
{
timestamp_minute: ISODate(“2013-10-10T23:06:00.000Z”),
num_samples: 58,
total_samples: 108000000,
type: “memory_used”,
values: {
0: 999999,
…
37: 1000000,
38: 1500000,
…
59: 1800000
}
}
When I save something like this via Mongoose, the keys in values are stored as strings (ex: "0", "1", ... , "59"). Is there any way to make these store as numeric keys?
当我通过Mongoose保存这样的东西时,值中的键被存储为字符串(例如:“0”,“1”,......,“59”)。有没有办法让这些商店成为数字键?
1 个解决方案
#1
0
Javascript object always non-numeric key. If you use numeric key, it will be converted as non-numeric or string.
Javascript对象始终是非数字键。如果使用数字键,则将其转换为非数字或字符串。
#1
0
Javascript object always non-numeric key. If you use numeric key, it will be converted as non-numeric or string.
Javascript对象始终是非数字键。如果使用数字键,则将其转换为非数字或字符串。