fix: query aggregation pipeline cannot handle value of type Date when directAccess: true (#8167)
This commit is contained in:
@@ -666,6 +666,23 @@ describe('Parse.Query Aggregate testing', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('should aggregate with Date object (directAccess)', async () => {
|
||||
const rest = require('../lib/rest');
|
||||
const auth = require('../lib/Auth');
|
||||
const TestObject = Parse.Object.extend('TestObject');
|
||||
const date = new Date();
|
||||
await new TestObject({ date: date }).save(null, { useMasterKey: true });
|
||||
const config = Config.get(Parse.applicationId);
|
||||
const resp = await rest.find(
|
||||
config,
|
||||
auth.master(config),
|
||||
'TestObject',
|
||||
{},
|
||||
{ pipeline: [{ $match: { date: { $lte: new Date() } } }] }
|
||||
);
|
||||
expect(resp.results.length).toBe(1);
|
||||
});
|
||||
|
||||
it('match comparison query', done => {
|
||||
const options = Object.assign({}, masterKeyOptions, {
|
||||
body: {
|
||||
|
||||
@@ -952,6 +952,9 @@ export class MongoStorageAdapter implements StorageAdapter {
|
||||
// an operator in it (like $gt, $lt, etc). Because of this I felt it was easier to make this a
|
||||
// recursive method to traverse down to the "leaf node" which is going to be the string.
|
||||
_convertToDate(value: any): any {
|
||||
if (value instanceof Date) {
|
||||
return value;
|
||||
}
|
||||
if (typeof value === 'string') {
|
||||
return new Date(value);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user