1.0.3 • Published 4 years ago

kowalski-analytics-storage-mongoose v1.0.3

Weekly downloads
1
License
MIT
Repository
github
Last release
4 years ago

kowalski-analytics-storage-mongoose

Mongoose Storage for Kowalski

Usage

const express = require('express')
const Kowalski = require('kowalski-analytics')
const mongoStorage = require('kowalski-analytics-storage-mongoose')

const app = express()

app.use(new Kowalski({
  informationToCollect: [ ... ],
  storage: mongoStorage('mongodb://mongdb_url_here/db_name')
}))

...

app.get('/getInformation/:informationName', (req, res, next) => {
  // req.kowalski.storage yields the mongoose instance
  req.kowalski.storage
    // model names are lower case
    .model(req.params.informationName.toLowerCase())
    .find()
    // result.information yields a Kowalski.Information instance
    .then(results => results.map(result => result.getInformation())) 
    .then(results => res.json(results))
    .catch(error => next(error))
})
1.0.2

4 years ago

1.0.1

4 years ago

1.0.3

4 years ago

1.0.0

4 years ago