trying a fix for redis

This commit is contained in:
Sébastien Drouyer 2012-11-03 15:35:31 +01:00
parent 4c8e4d8e4d
commit 7930af6eba
1 changed files with 60 additions and 62 deletions

View File

@ -453,16 +453,12 @@ function testOrm(schema) {
if (schema.name !== 'mongodb') if (schema.name !== 'mongodb')
it('hasMany should support additional conditions', function (test) { it('hasMany should support additional conditions', function (test) {
// We try to get the first post with a userId != NULL
var search = {};
if (schema.name === 'mongodb') { // On mongodb, complex conditions are not supported
search = {order: 'userId DESC'};
} else {
search = {where: {userId: {'gt': 0}}};
}
// Finding one post with an existing author associated // Finding one post with an existing author associated
Post.findOne(search, function (err, post) { Post.all(function (err, posts) {
// We try to get the first post with a userId != NULL
for (var i = 0; i < posts.length; i++) {
var post = posts[i];
if (post.userId !== null) {
// We could get the user with belongs to relationship but it is better if there is no interactions. // We could get the user with belongs to relationship but it is better if there is no interactions.
User.find(post.userId, function(err, user) { User.find(post.userId, function(err, user) {
user.posts({where: {id: post.id}}, function(err, posts) { user.posts({where: {id: post.id}}, function(err, posts) {
@ -470,21 +466,20 @@ function testOrm(schema) {
test.done(); test.done();
}); });
}); });
break;
}
}
}); });
}); });
it('hasMany should be cached', function (test) { it('hasMany should be cached', function (test) {
// We try to get the first post with a userId != NULL
var search = {};
if (schema.name === 'mongodb') { // On mongodb, complex conditions are not supported
search = {order: 'userId DESC'};
} else {
search = {where: {userId: {'gt': 0}}};
}
// Finding one post with an existing author associated // Finding one post with an existing author associated
Post.findOne(search, function (err, post) { Post.all(function (err, posts) {
// We try to get the first post with a userId != NULL
for (var i = 0; i < posts.length; i++) {
var post = posts[i];
if (post.userId !== null) {
// We could get the user with belongs to relationship but it is better if there is no interactions. // We could get the user with belongs to relationship but it is better if there is no interactions.
User.find(post.userId, function(err, user) { User.find(post.userId, function(err, user) {
User.create(function(err, voidUser) { User.create(function(err, voidUser) {
@ -537,6 +532,9 @@ function testOrm(schema) {
}); });
}); });
}); });
break;
}
}
}); });
}); });