Skip to content

voitau/loopback-examples

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

StrongLoop [LoopBack.JS] (https://github.com/strongloop/loopback) usage examples

Push notifications

Shows how to set up and test push notifications.

  beforeEach(function(done) {
    pushStub = sinon.stub(app.models.Push, 'notifyByQuery', function(query, notification, cb) { cb(); });
    done();
  });

  afterEach(function(done) {
    pushStub.restore();
    done();
  });

  it('should send push notification when created', function(done) {
    Event.create({title: 'Party'}, function(err, results) {
      pushStub.calledOnce.should.eql(true);
      var pushStubCall = pushStub.getCall(0);

      var query = pushStubCall.args[0];
      query.should.eql({});

      var notification = pushStubCall.args[1];
      notification.title.should.eql('Party');
      done();
    });
  });

Full example is here: push-notifications/

Mongo connector

Shows how to use custom mongo operators.

  petition.updateAttributes({'$set': {description: 'v1'}, '$inc': {version: 1}}, function(err, petitionUpdated) {
    if (err) return done(err);
    Petition.findById(petitionUpdated.id, function(err, petitionFound) {
      if (err) return done(err);
      petitionFound.description.should.eql('v1');
      petitionFound.version.should.eql(1);
      done();
    });
  });

Full example is here: mongo-connector/

About

StrongLoop LoopBack usage examples

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors