Why is this date sorting not working?


I’m trying to sort the queries by date but it is not working as it gives me an error

useEffect(async () => {

        const pipeline = { sort : { updatedAt : 1 } }

        return data.aggregate(pipeline)

        const results = JSON.stringify(x, null, 2)

        const finalResult = JSON.parse(results)


    }, [])

what is the error that you get?

TypeError: data.aggregate is not a function

data is gotten from a inbuild moralis function in react

	const { data, error, isLoading } = useMoralisQuery("Posts");

what is data in your case?

Posts query which contains all the posts

if you already have all the posts, you could sort them maybe differently directly in javascript, that syntax with aggregate is similar to do a sort in a query