Skip to content

Latest commit

 

History

History
88 lines (54 loc) · 1.66 KB

File metadata and controls

88 lines (54 loc) · 1.66 KB

MongoDb

Learn how to store user specific data of your Alexa Skills and Google Actions to a MongoDb database.

Introduction

The MongoDb database integration allows you to store user specific data into the widely supported documented-oriented NoSQL-database.

Configuration

Download the package like this:

$ npm install --save jovo-db-mongodb

MongoDb can be enabled in the src/app.js file like this:

// @language=javascript

// src/app.js

const { MongoDb } = require('jovo-db-mongodb');

// Enable DB after app initialization
app.use(new MongoDb());

// @language=typescript

// src/app.ts

import { MongoDb } from 'jovo-db-mongodb';

// Enable DB after app initialization
app.use(new MongoDb());

In your config.js file, you can set the db configuration like this:

// @language=javascript

// src/config.js

module.exports = {
    
    db: {
        MongoDb: {
            databaseName: 'yourDatabaseName',
        collectionName: 'yourCollectionName',
        uri: 'yourMongoDbURI',
        },
    },

    // ...

};

// @language=typescript

// src/config.ts

const config = {
    
    db: {
        MongoDb: {
            databaseName: 'yourDatabaseName',
        collectionName: 'yourCollectionName',
        uri: 'yourMongoDbURI',
        },
    },

    // ...

};

If you don't specify a collection name, a default collection UserData will be created in your specified database.