Giter VIP home page Giter VIP logo

angularjs-mongolab's People

Contributors

novito avatar pkozlowski-opensource 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  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  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

Watchers

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

angularjs-mongolab's Issues

getByIds enhancement

Right now the getByIds function works with wrapping the provided ids in a MongoDB $oid object.
Assuming you merge my last PR this won't work in all cases. We also have to search for the bare ids.

We could either make the getByIds query a bit more complicated in order to keep the API simple:

Resource.getByIds = function (ids, successcb, errorcb) {
      var qin = [];
      angular.forEach(ids, function (id) {
        qin.push({$oid:id});
      });
      return Resource.query({$or:[{id_:{$in:qin}},{id_:{$in:ids}}]}, successcb, errorcb);
};

or add another method, which queries using bare ids.

Or simply use the query method if one wants to query with bare ids.

Improving the current query would keep the API simple, but has drawback in performance.

What would you recommend?

I can pass a dinamic collection?

As I spend a dynamic collection to the factory?

I'm trying some ways and still can not, I tried to pass the parameter :collection, but does not.

Any idea?

.factory('ALL', function($mongolabResourceHttp) {
//Here get the collection, pass from controller...
return $mongolabResourceHttp(COLLECTION);
})

CONTROLLER:
ALL.all(COLLECTION, { limit: 10 }).then(function(response) {
$scope.dashboardposts = response.data;
});

How to use instance level methods?

Thankyou for making this --- this is a real time saver. A quick example on how to use the instance level methods here would be very helpful to me :)

resource.$id()
resource.$save(successcb, errorcb)
resource.$update(successcb, errorcb)
resource.$saveOrUpdate(successcb, updateSuccesscb, errorcb, updateErrorcb)
resource.$remove(successcb, errorcb)

For example if I have a given $oid how could I directly update that record or delete it? How do I directly add a new record to a collection?

Getting success callbacks on success AND errors.

I have been having some success using this module to help streamline my database interactions, so far so good.

I am getting a query resource to read as expected. The managers object gets passed into my template $scope and the log shows a "read success" message - Good.

In wanting to next deal with error conditions, I find that passing in a known bad ID still takes the same path to the successCB, the errorCB should fire but does not. Have I set this up wrong or made a wrong assumption? Thanks.

.controller('ContactCtrl', function($scope, $rootScope, $log, ManagersCollection) {
  var criteriaObject = { im_id: "alang" };
  var sortObject = { sort: { _id: 1 } };
  var successCB  = function(managers) {
    $scope.manager = managers[0];  // use [0] for the first selected item.
    $log.log( "Managers ID " + criteriaObject.im_id + " read success" );
  };
  var errorCB = function(managers) {
    throw new Error(criteriaObject.im_id + ' item read went wrong...');
  };

  ManagersCollection.query(
    criteriaObject,
    sortObject,
    successCB,
    errorCB
  );
})

Error on save when pushing into array

I have a need to take data entered into the form and do calculations on it then push the result into the model as well as the original values. The problem I'm having is that I get an error when trying to save or saveOrUpdate to my mongolab db. It appears that if I mess with the model it removes all the methods you've created. Can what I need to do be done with this or will I need to dig into the MongoLab API and go server-side from the beginning?

To demonstrate I'm taking the Name & Site and concatenating them and pushing the result into the model: http://plnkr.co/edit/mfS046?p=preview

Great resource though. I like it!

Security

Am I missing something or do I have to put my mongolab API key into the javascript that gets shipped to my users browsers?

angular.equals(queryJson,{}) is giving me an incorrect 'true'

When passing in what seems to be a perfectly good object for queryJson such as

{"$or":[
    {"attrib1": {"$regex":"some", "$options":"i"}},
    {"attrib2": {"$regex":"", "$options":"i"}}
    ]
}

into preparyQueryParam() , but when this runs...

angular.equals(queryJson,{}) // fragment of line 37 of mongolabResourceHttp.js

I (incorrectly) get true ๐ŸŽฑ

I looked into this and it _may_ have to do with a bug in angular when an object has an undefined value {"test":undefined} or it may have something to do with the dollar sign $keys needed for mongodb, I am not sure.

I am working on a fix...

brackets for api key

included in your example for where you add the API-KEY:
app.constant('MONGOLAB_CONFIG',{API_KEY:'[your key goes here]', DB_NAME:'angularjs'});

The brackets around the api-key cause problems for me. Works fine once they're gone.

Promise not working in Firefox?

I'm not sure if I'm doing something wrong, but when I want to save my data to DB, I use following code:

Project.$saveOrUpdate().then(function(returnData){
    $scope.savedData = returnData;
  });

In Firefox I can't get information if data is saved successfully or not. It never executes callback function, but the data is saved.

As far as I understand, the old way of providing callback functions in .$saveOrUpdate(success, error) is not anymore valid way of getting that?

Error callback called on successfull write operations

The $http service seems to interpret status code 201 (mongolab returns this) as an error. Every time I save a record both success and error callback are called.
I would suggest we handle the responses ourselves and then call the user's callback based on the status code.

Private mongodb credentials in production environment

Sorry if this is a very beginner question but...

Is there a way of using this in a production environment, and be able to keep your database credentials private?

I ask because this puts all the database work on the client side, right?

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.