Giter Site home page Giter Site logo

botkit-storage-mongo's Introduction

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

});

botkit-storage-mongo's People

Contributors

anonrig avatar colestrode avatar benbrown avatar johanhenrikssn avatar oiorain avatar alexsmanning avatar shindakun avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.