Why is this date sorting not working?

Hey,

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)

        setResults(finalResult)

    }, [])

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

hm ok. Do you know why in the dashboard browser updated and createdAt are named “createdAt” and “updatedAt” but when connecting via some mongo db UI tool the columns are named _updated_at and_created_at ?

that is an internal naming for some columns that are used different by the server, most of what you see here is from parse server that is used by moralis