Code Monkey home page Code Monkey logo

ng-couchbase-lite's Introduction

ng-couchbase-lite

This is an AngularJS wrapper to be used with the Couchbase Lite RESTful APIs. It makes it so you don't have to do all the requests manually, but instead can call simple commands.

Installation

Include the repositories dist/ng-couchbase-lite.min.js file into your mobile hybrid application's project directory. With the file in place, include the script in your HTML file, typically index.html. Finally inject the library into your AngularJS angular.module in a similar fashion to the following:

angular.module("modulename", ["ngCouchbaseLite"])

Usage

To use, inject $couchbase into your controller dependencies and call the constructor method:

var database = new $couchbase(databaseUrl, databaseName);

Note that the databaseUrl is the URL that is returned when using the cblite.getURL method that ships with the Apache Cordova Couchbase plugin.

Available Commands

promise database.createDatabase();
promise database.getDatabase();
promise database.createDesignDocument(string designDocumentName, object designDocumentViews);
promise database.createDocument(object json);
promise database.getDesignDocument(string designDocumentName);
promise database.queryView(string designDocumentName, string viewName);
promise database.updateDocument(string documentId, string documentRevision, object jsonObject);
promise database.deleteDocument(string documentId, string documentRevision);
promise database.getAllDocuments();
promise database.getDocument(string documentId);
promise database.replicate(string source, string target, boolean continuous);
void    database.listen();

Need Help?

Visit the Couchbase Forums and open a ticket under the mobile section.

Resources

Couchbase Lite REST API - http://developer.couchbase.com/mobile/develop/references/couchbase-lite/rest-api/index.html

ng-couchbase-lite's People

Contributors

matheusrocha89 avatar nraboy avatar swaheed2 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ng-couchbase-lite's Issues

Add implementation for fetch

The only difference in code would be in the makeRequest method. Should we create a new repo on GitHub called something like couchbase-lite-fetch or keep the fetch and angularjs service in the same repo/npm module? There would then be different require statements for each REST API wrapper.

can we add a getter for databaseUrl to use the makeRequest function

I was trying to monitor progress using GET /_active_tasks and realized in order to to use the makeRequest function, I need database url. We already provided it to the factory when we did:

database = new $couchbase(url, appDbName);

Why not have it available for later use like database.getUrl()

_design in design document name

The createDesignDocument and queryView methods require the design document name to be of the form _design/{name}. Removing the requirement to have _design/ would make it simpler to use.

queryView not working with key parmeter

I have spent hours on this, but can't figure out a solution.

This is one of my view:

AllAccounts : {
    map : function(doc) {
        if (doc.type === "group") {
            emit(doc.id,doc.id)
        }
    }.toString()
} 

When I use coax library from https://github.com/couchbaselabs/Couchbase-Lite-PhoneGap-Plugin , it works perfectly fine:

config.views(['AllAccounts', { key: "351658"} ],function(err,res){
    console.log(JSON.stringify(res,null,2))
})

result:


  "offset": 0,
  "total_rows": 5,
  "rows": [
    {
      "doc": null,
      "id": "group_351658",
      "value": "351658",
      "key": "351658"
    }
  ] 

But when I switched to this library that uses $http and I do this:

var params = {  "key" : "351658" , "include_docs" : true }; 
return databse.queryView(config.designDoc,"PartyEventsPending", params); 

I get:

{"offset":0,"total_rows":5,"rows":[]}

I have tried alot of things and in my conclusion since the coax request is like this:

http://0d5f9215-adc7-4098-993a-9a73e036aba4:edeabc2c-1024-459c-bbdc-19480edd7fcb@localhost:5986/todos/_design%2Ftodo10/_view/AllAccounts?key=%22351658%22

and $http request is like this from this library:

http://ad6f4d60-65eb-44bc-a6bd-a6bf3a7f14de:d39661b1-e347-4cf1-a837-1a4520b29915@localhost:5984/todos/_design/todo10/_view/AllAccounts?key=351658

This might be causing the problem. I need help asap please.

BTW, without key param, it works perfectly fine:

{
  "offset": 0,
  "total_rows": 5,
  "rows": [
    {
      "doc": null,
      "id": "group_109719",
      "value": "109719",
      "key": "109719"
    },
    {
      "doc": null,
      "id": "group_109719",
      "value": "109775",
      "key": "109775"
    },
    {
      "doc": null,
      "id": "group_109719",
      "value": "111480",
      "key": "111480"
    },
    {
      "doc": null,
      "id": "group_109719",
      "value": "116329",
      "key": "116329"
    },
    {
      "doc": null,
      "id": "group_351658",
      "value": "351658",
      "key": "351658"
    }
  ]
}

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.