GithubHelp home page GithubHelp logo

kule's Introduction

Simple REST Interface for MongoDB.

Kule is a REST interface for MongoDB. You can use kule as a temporary backend for your backend needed apps.

Requirements

  • Bottle
  • Pymongo

Usage

python -m kule --database foo --collections users,documents

That's all.

Kule

Now you can interact with your API.

Method Path Action
GET /users Returns all records. You can give limit and offset parameters to paginate records.
GET /users/:id Returns a single document
POST /users Creates a new document
PUT /users/:id Replaces an existing document
PATCH /users/:id Updates a document
DELETE /users/:id Removes an existing document

Customization

You can customize your API response for your requirements. For example, you can provide authentication method.

Example

You can override an existing endpoint.

from kule import Kule

class MyKule(Kule):
    def delete_detail(self, collection, pk):
        return self.not_implemented()

get_foo_list, put_foo_detail ...

You can override specific endpoint with kule's magical methods.

from kule import Kule

class MyKule(Kule):
    def get_users_list(self, collection):
        return ["merhaba", "hello", "hola"]

build_foo_bundle

Also there is a way to build customized bundles.

from kule import Kule

class MyKule(Kule):
    def build_users_bundle(self, user):
        first_name, last_name = user.get("full_name").split()
        return {
            "first_name": first_name,
            "last_name": last_name
        }

Starting app

mykule = MyKule(database="foo")
mykule.run()

Using with Backbone.js

You have to override the parse method of collections. Because models listing on objects key.

Backbone.Collection.prototype.parse = function(data) {
    return data.objects ? data.objects : data;
};

// examples
var Document = Backbone.Model.extend({
    urlRoot: "/documents",
    idAttribute: "_id"
});
var Documents = Backbone.Collection.extend({
    model: Document,
    url: "/documents"
});

// lets play
var _document = new Document({"title": "hello"});
_document.save()

kule's People

Watchers

 avatar  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.