Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.x fix/upsert #129

Merged
merged 4 commits into from
May 11, 2017
Merged

1.x fix/upsert #129

merged 4 commits into from
May 11, 2017

Conversation

jannyHou
Copy link
Contributor

@jannyHou jannyHou commented May 9, 2017

related to #111

@jannyHou
Copy link
Contributor Author

@slnode test please

Copy link

@Amir-61 Amir-61 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More comments to improve the code; also it needs squash as well.

afterEach(function(done) {
Product.destroyById(1, function(err) {
if (err) return done(err);
done();
Copy link

@Amir-61 Amir-61 May 10, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of:

function(err) {
  if (err) return done(err);
  done();
}

Just the following line is enough:

done(err)

if (err) return done(err);
res.id.should.equal('1');
res.name.should.equal('bread');
// scenario: upsert does a update
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

an update

Product.upsert({
id: '1',
name: 'newBread',
}, function(err, res) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check err here as well.

});
});

it('can call upsert with an id and have it create a document without error',
Copy link

@Amir-61 Amir-61 May 10, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably the following is what you are achieving here:

can call upsert with a primary key and create/update a document without error

Also it is always a good idea if you try primary keys which are not id as well.

@jannyHou jannyHou added blocked and removed review labels May 10, 2017
@jannyHou jannyHou merged commit 7a2de53 into loopbackio:1.x May 11, 2017
@jannyHou jannyHou added this to the Sprint 35 - Apex milestone May 11, 2017
kjdelisle pushed a commit that referenced this pull request May 11, 2017
 * 1.x fix/upsert (#129) (Janny)
 * cloudant: allow passthrough of settings (#114) (Sakib Hasan)
 * Fix cloudant url for CI (Diana Lau)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants