Skip to content

Conversation

@saturnonearth
Copy link
Collaborator

I attempted to add support for the ttl param to the Query function.

For more info on TTL, see here: https://zero.rocicorp.dev/docs/reading-data#background-queries

I am very new to this type of this so if anyone could check my work that would be great.

I tried to replicate close to the React version of useQuery as possible, seen here:
https://github.com/rocicorp/mono/blob/831038b2d938672634cdbbe7f92b2c7342245ffe/packages/zero-react/src/use-query.tsx#L345

@Abdelrahmanaman
Copy link

ttl doesn't exist on the query, is it being used?

@saturnonearth
Copy link
Collaborator Author

ttl doesn't exist on the query, is it being used?

It goes inside new Query as a param. For example -

	let documents = new Query(
		z.current.query.documents.where('userId', user.id).orderBy('modified', 'desc'),
		{
			ttl: '1m'
		}
	);

I am a little out of element here but it seemed to work for me. Is it not working on your end?

@saturnonearth
Copy link
Collaborator Author

saturnonearth commented Aug 7, 2025

I adjusted to fit the new spec for default of '5m' for all queries. Also removed 'UpdateQuery' as it wasn't used.

See changelog:
https://zero.rocicorp.dev/docs/release-notes/0.22

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants