I currently have a time series collection and I am exposing it with the Atlas Data API.
This is the general schema of my documents
{
"time": "2022-01-05T09:34:00.000Z",
"coin": "avax",
"_id": "61d566111c94337a77a8bdbb",
"value": 3.64,
"currency": "usd"
}
Now I am able to filter my query with the ‘time’ field when
- I am using MongoDB NodeJS driver
- However when I try to run the same query using Data API, it doesn’t work (it doesn’t return any result when with the NodeJS driver it does).
MongoDB NodeJS Example
const result = await coins.find({
coin: coin,
time: {
"$gte": new Date('2022-01-04')
}
}).toArray();
Same Example using the Data API
export const fetchCall = async (type, filter) => {
let data = {
"collection": "Coins",
"database": "Prices",
"dataSource": "DataAPITestCluster",
"filter": {
time: {
"$gt": new Date('2022-01-04')
}
}
};
let config = {
method: 'post',
url: `https://data.mongodb-api.com/app/data-ycafa/endpoint/data/beta/action/${type}`,
headers: {
'Content-Type': 'application/json',
'Access-Control-Request-Headers': '*',
'api-key': key
},
data: data
};
return axios(config)
}
Is this an issue with the Data API not recognizing ‘date’ types?