🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis →
Socket
Book a DemoInstallSign in
Socket

botkit-storage-mongo

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

botkit-storage-mongo

A MongoDB storage driver for Botkit

latest
Source
npmnpm
Version
1.0.7
Version published
Weekly downloads
80
-59.8%
Maintainers
1
Weekly downloads
 
Created
Source

botkit-storage-mongo

npm David npm bitHound Overall Score

A Mongo storage module for Botkit that provides a simple system for storing information about a user, a channel, or a team.

This project is an extension to Botkit Core, a richly featured developer toolkit for building bots and conversational apps.

This module conforms to Botkit's storage plugin convention.

Usage

Just require botkit-storage-mongo and pass it a config with a mongoUri option. In addition, you may pass a tables parameter, which will create methods for accessing additional tables (other than user, channel and team) in your Mongo database. Then pass the returned storage when creating your Botkit controller. Botkit will do the rest.

Make sure everything you store has an id property, that's what you'll use to look it up later.

var Botkit = require('botkit'),
    mongoStorage = require('botkit-storage-mongo')({mongoUri: '...', tables: ['optional','list', 'of', 'custom','tables', 'to', 'add']}),
    controller = Botkit.slackbot({
        storage: mongoStorage
    });
// then you can use the Botkit storage api, make sure you have an id property
var beans = {id: 'cool', beans: ['pinto', 'garbanzo']};
controller.storage.teams.save(beans);
controller.storage.teams.get('cool', function(error, beans){
    // do something with beans
});

You can also get all entries from a table or find a selected set depending on a parameters.

storage.users.all(function(error, users){
    // do something with users
});
storage.users.find({team_id: team_id}, function(error, users){
    // do something with users
});

As of 1.0.6, all functions also support Promise syntax:

storage.users.all().then(function(list_of_users) {

  // do something

});

Keywords

botkit

FAQs

Package last updated on 27 Jul 2017

Did you know?

Socket

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.

Install

Related posts