-
Notifications
You must be signed in to change notification settings - Fork 237
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Raymond Feng
committed
Jan 24, 2014
1 parent
0918675
commit 2790056
Showing
7 changed files
with
535 additions
and
533 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,51 @@ | ||
var DataSource = require('loopback-datasource-juggler').DataSource; | ||
|
||
var config = require('rc')('loopback', {dev: {mongodb:{}}}).dev.mongodb; | ||
var config = require('rc')('loopback', {dev: {mongodb: {}}}).dev.mongodb; | ||
|
||
var ds = new DataSource(require('../'), config); | ||
|
||
var Customer = ds.createModel('customer', {seq: {type: Number, id: true}, name: String, emails: [String], age: Number}); | ||
|
||
Customer.create({ | ||
seq: 1, | ||
name: 'John1', | ||
emails: ['john@x.com', 'john@y.com'], | ||
age: 30 | ||
}, function(err, customer) { | ||
console.log(customer.toObject()); | ||
seq: 1, | ||
name: 'John1', | ||
emails: ['john@x.com', 'john@y.com'], | ||
age: 30 | ||
}, function (err, customer) { | ||
console.log(customer.toObject()); | ||
|
||
/* | ||
customer.updateAttributes({name: 'John'}, function(err, result) { | ||
console.log(err, result); | ||
}); | ||
/* | ||
customer.updateAttributes({name: 'John'}, function(err, result) { | ||
console.log(err, result); | ||
}); | ||
customer.delete(function(err, result) { | ||
customer.updateAttributes({name: 'JohnX'}, function(err, result) { | ||
console.log(err, result); | ||
}); | ||
customer.delete(function(err, result) { | ||
customer.updateAttributes({name: 'JohnX'}, function(err, result) { | ||
console.log(err, result); | ||
}); | ||
}); | ||
*/ | ||
}); | ||
*/ | ||
|
||
Customer.findById(customer.seq, function(err, customer) { | ||
console.log(customer.toObject()); | ||
Customer.findById(customer.seq, function (err, customer) { | ||
console.log(customer.toObject()); | ||
|
||
customer.name = 'John'; | ||
customer.save(function(err, customer) { | ||
console.log(customer.toObject()); | ||
ds.connector.close(); | ||
}); | ||
customer.name = 'John'; | ||
customer.save(function (err, customer) { | ||
console.log(customer.toObject()); | ||
ds.connector.close(); | ||
}); | ||
}); | ||
}); | ||
|
||
/* | ||
Customer.create({ | ||
id: 2, | ||
name: 'John2', | ||
emails: ['john@x.com', 'jhon@y.com'], | ||
age: 30 | ||
}, function(err, customer) { | ||
console.log(customer.toObject()); | ||
}); | ||
*/ | ||
Customer.create({ | ||
id: 2, | ||
name: 'John2', | ||
emails: ['john@x.com', 'jhon@y.com'], | ||
age: 30 | ||
}, function(err, customer) { | ||
console.log(customer.toObject()); | ||
}); | ||
*/ |
Oops, something went wrong.