Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
mongoose-timeseries
Advanced tools
a time series data and analytics storage plugin for Mongoose.
npm install mongoose-timeseries
var YourDocumentSchema = new Schema({
attr1: { type: Schema.Types.ObjectId, ref: 'attr1' },
attr2: { type: Schema.Types.ObjectId, ref: 'attr2' },
date: { type: Date, default: Date.now },
metric: { type: Number },
info: {
sub1: { type: String },
sub2: { type: String },
sub3: { type: String }
}
})
var mongoose = require('mongoose')
var timeseries = require('mongoose-timeseries')
YourDocumentSchema.plugin(timeseries, {
name: 'TimeSeriesDocument',
dateKey: 'date',
intervals: ['minute', 'day'],
keys: [
{
key: 'attr1'
},
{
key: 'attr2'
},
{
key: 'info',
value: function(doc) {
return doc.sub1 + doc.sub2 + doc.sub3
}
}
],
data: [
{
key: 'metric',
sum: true
}
]
})
Saved time series documents will look like:
{
interval: 'day',
timestamp: Mon Aug 01 2016 00:00:00 GMT-0600(MDT),
created: Mon Aug 01 2016 00:51:09 GMT-0600(MDT),
updated: Wed Aug 31 2016 22:19:42 GMT-0600(MDT),
data: {
count: 5,
metric: {
sum: 697,
count: 5
}
},
key: {
attr1: 55931aba4f3b26d63810a55d,
attr2: 5536011b00a57af8243d7e5b,
info: 'ABC'
},
_id: 57 a50178e47cea6f5d7f1c3b
}
YourDocumentSchema.plugin(timeseries, options(Object))
You can apply multiple times with different options:
YourDocumentSchema.plugin(timeseries, options1(Object))
YourDocumentSchema.plugin(timeseries, options2(Object))
YourDocumentSchema.plugin(timeseries, options3(Object))
The collection name of the specific time series data:
name(String)
The custom date key of your schema (if applicable):
If not set, defaults to document._id.getTimeStamp()
dateKey(String)
The time series intervals you want: Can include any or all of ['minute', 'hour', 'day', 'month']
intervals(Array)
The unique information you'd like your time series to seperate and store:
keys(Array)
The name of the key:
keys.key(String)
The function that returns your a value to store on the associated key: Defaults to the name of the key
keys.value(Function)
The data you'd like your time series to count and sum:
data(Array)
The name of the data key:
data.key(String)
Boolean to sum the datapoint (only works for Number attributes)
data.sum(Boolean)
npm install
npm test
FAQs
a time series data and analytics storage plugin for Mongoose
The npm package mongoose-timeseries receives a total of 0 weekly downloads. As such, mongoose-timeseries popularity was classified as not popular.
We found that mongoose-timeseries demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.