-
Notifications
You must be signed in to change notification settings - Fork 21
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
1.x fix/upsert #129
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -112,6 +112,37 @@ describe('cloudant connector', function() { | |
}; | ||
}); | ||
}); | ||
|
||
describe('updateOrCreate', function() { | ||
afterEach(function(done) { | ||
Product.destroyById(1, function(err) { | ||
if (err) return done(err); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('can call upsert with an id and have it create a document without error', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably the following is what you are achieving here:
Also it is always a good idea if you try primary keys which are not |
||
function(done) { | ||
// scenario: upsert does a create | ||
Product.upsert({ | ||
id: '1', | ||
name: 'bread', | ||
}, function(err, res) { | ||
if (err) return done(err); | ||
res.id.should.equal('1'); | ||
res.name.should.equal('bread'); | ||
// scenario: upsert does a update | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. an update |
||
Product.upsert({ | ||
id: '1', | ||
name: 'newBread', | ||
}, function(err, res) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please check |
||
res.id.should.equal('1'); | ||
res.name.should.equal('newBread'); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('cloudant constructor', function() { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of:
Just the following line is enough: