I'm on a Node.js Sails app 0.10-rc4 with Waterline on mongoDB (sails-mongo adapter), and I've a model.where criteria condition that works good:
or:
[
{
start:
{
'>': new Date(parseInt(req.param('start'))*1000),
'<': new Date(parseInt(req.param('end'))*1000)
},
end:
{
'>': new Date(parseInt(req.param('start'))*1000),
'<': new Date(parseInt(req.param('end'))*1000)
}
}
]
... but I wanted to add a exception on it, something in algo that's like that :
(
(startq > startparam AND startq < endparam)
OR
(endq > startparam AND endq < endparam)
)
OR
(
(startq < startparam AND endq > endparam)
)
... but it seems like we can't use more than one OR ?
or:
[
{
start:
{
'>': new Date(parseInt(req.param('start'))*1000),
'<': new Date(parseInt(req.param('end'))*1000)
},
end:
{
'>': new Date(parseInt(req.param('start'))*1000),
'<': new Date(parseInt(req.param('end'))*1000)
},
{
start:
{
'<': new Date(parseInt(req.param('start'))*1000)
},
end:
{
'>': new Date(parseInt(req.param('end'))*1000)
}
}
}
]
I've tried many ways (with of without bracket)...
or:
[
{
{
or:
[
{
start:
{
'>': new Date(parseInt(req.param('start'))*1000),
'<': new Date(parseInt(req.param('end'))*1000)
},
end:
{
'>': new Date(parseInt(req.param('start'))*1000),
'<': new Date(parseInt(req.param('end'))*1000)
}
}
]
},
{
start:
{
'<': new Date(parseInt(req.param('start'))*1000)
},
end:
{
'>': new Date(parseInt(req.param('end'))*1000)
}
}
}
]
... no one worked, most for the time I got:
SyntaxError: Unexpected token {
The docs don't have examples on that syntax, there is a way to do it ?
EDIT:
Thx to Scott, here is the good syntax:
or:
[
{
start:
{
'>': new Date(parseInt(req.param('start'))*1000),
'<': new Date(parseInt(req.param('end'))*1000)
}
},
{
end:
{
'>': new Date(parseInt(req.param('start'))*1000),
'<': new Date(parseInt(req.param('end'))*1000)
}
},
{
start:
{
'<': new Date(parseInt(req.param('start'))*1000)
},
end:
{
'>': new Date(parseInt(req.param('end'))*1000)
}
}
]