Changeset View
Changeset View
Standalone View
Standalone View
lib/chip-types/datastore.js
Show First 20 Lines • Show All 153 Lines • ▼ Show 20 Lines | .then(function() { | ||||
); | ); | ||||
return Promise.resolve(complex_object); | return Promise.resolve(complex_object); | ||||
}); | }); | ||||
}) | }) | ||||
.then(function(complex_object) { | .then(function(complex_object) { | ||||
// Should handle dot-notation nested queries | // Should handle dot-notation nested queries | ||||
return self | return self | ||||
.find(test_collection_name, { | .find(test_collection_name, { | ||||
"body.name": complex_object.body.name, | name: complex_object.name, | ||||
}) | }) | ||||
.then(function(response) { | .then(function(response) { | ||||
assert.deepEqual( | assert.deepEqual( | ||||
complex_object, | complex_object, | ||||
response[0], | response[0], | ||||
".find method should handle dot notation queries" | ".find method should handle dot notation queries" | ||||
); | ); | ||||
return Promise.resolve(complex_object); | return Promise.resolve(complex_object); | ||||
}); | }); | ||||
}) | }) | ||||
.then(function(complex_object) { | .then(function(complex_object) { | ||||
return self | return self | ||||
.find(test_collection_name, { | .find(test_collection_name, { | ||||
body: { | body: { | ||||
name: complex_object.body.name, | name: complex_object.name, | ||||
}, | }, | ||||
}) | }) | ||||
.then(function(response) { | .then(function(response) { | ||||
assert.deepEqual( | assert.deepEqual( | ||||
complex_object, | complex_object, | ||||
response[0], | response[0], | ||||
".find method should handle nested object queries" | ".find method should handle nested object queries" | ||||
); | ); | ||||
return Promise.resolve(complex_object); | return Promise.resolve(complex_object); | ||||
}); | }); | ||||
}) | }) | ||||
.then(function(complex_object) { | .then(function(complex_object) { | ||||
// .update should modify document values with dot notation | // .update should modify document values with dot notation | ||||
complex_object.body.name = "Hanna"; | complex_object.name = "Hanna"; | ||||
return self | return self | ||||
.update( | .update( | ||||
test_collection_name, | test_collection_name, | ||||
{ | { | ||||
id: complex_object.id, | id: complex_object.id, | ||||
}, | }, | ||||
{ | { | ||||
"body.name": complex_object.body.name, | name: complex_object.name, | ||||
} | } | ||||
) | ) | ||||
.then(function() { | .then(function() { | ||||
return self.find(test_collection_name, { | return self.find(test_collection_name, { | ||||
id: complex_object.id, | id: complex_object.id, | ||||
}); | }); | ||||
}) | }) | ||||
.then(function(results) { | .then(function(results) { | ||||
assert.deepEqual( | assert.deepEqual( | ||||
complex_object, | complex_object, | ||||
results[0], | results[0], | ||||
".update should modify document values with dot notation" | ".update should modify document values with dot notation" | ||||
); | ); | ||||
return Promise.resolve(complex_object); | return Promise.resolve(complex_object); | ||||
}); | }); | ||||
}) | }) | ||||
.then(function(complex_object) { | .then(function(complex_object) { | ||||
// .update should modify document values using nested object as a query | // .update should modify document values using nested object as a query | ||||
complex_object.body.name = "Marzanna"; | complex_object.name = "Marzanna"; | ||||
return self | return self | ||||
.update( | .update( | ||||
test_collection_name, | test_collection_name, | ||||
{ | { | ||||
id: complex_object.id, | id: complex_object.id, | ||||
}, | }, | ||||
{ | { | ||||
body: { | body: { | ||||
name: complex_object.body.name, | name: complex_object.name, | ||||
}, | }, | ||||
} | } | ||||
) | ) | ||||
.then(function() { | .then(function() { | ||||
return self.find(test_collection_name, { | return self.find(test_collection_name, { | ||||
id: complex_object.id, | id: complex_object.id, | ||||
}); | }); | ||||
}) | }) | ||||
.then(function(results) { | .then(function(results) { | ||||
assert.deepEqual( | assert.deepEqual( | ||||
complex_object, | complex_object, | ||||
results[0], | results[0], | ||||
".update should modify document values using nested object as a query " | ".update should modify document values using nested object as a query " | ||||
); | ); | ||||
return Promise.resolve(complex_object); | return Promise.resolve(complex_object); | ||||
}); | }); | ||||
}) | }) | ||||
.then(function(complex_object) { | .then(function(complex_object) { | ||||
// .update should insert new value to a field that previously had no value (undefined) | // .update should insert new value to a field that previously had no value (undefined) | ||||
complex_object.body.other = "Focca"; | complex_object.other = "Focca"; | ||||
return self | return self | ||||
.update( | .update( | ||||
test_collection_name, | test_collection_name, | ||||
{ | { | ||||
id: complex_object.id, | id: complex_object.id, | ||||
}, | }, | ||||
{ | { | ||||
body: { | body: { | ||||
other: complex_object.body.other, | other: complex_object.other, | ||||
}, | }, | ||||
} | } | ||||
) | ) | ||||
.then(function() { | .then(function() { | ||||
return self.find(test_collection_name, { | return self.find(test_collection_name, { | ||||
id: complex_object.id, | id: complex_object.id, | ||||
}); | }); | ||||
}) | }) | ||||
▲ Show 20 Lines • Show All 79 Lines • Show Last 20 Lines |