Open airtonix opened 5 months ago
What's the design vision with regards to this?
const posts = await query( from(collection.items), where((item) => { if (import.meta.env.MODE === 'development') { return true; } return item.stage !== 'draft'; }), ) ... const post = await query( from(posts), where((item) => { if (item.metadata.slug !== params.slug) { return false; } }), )
or are we expected to do :
const whereDraftOnlyInDevelopment = where((item) => { if (import.meta.env.MODE === 'development') { return true; } return item.stage !== 'draft'; }) const whereSlugEqualsParam = (slug: string) => where((item) => { if (item.metadata.slug !== slug) { return false; } }) const posts = await query( from(collection.items), whereDraftOnlyInDevelopment, ) ... const post = await query( from(collection.items), whereDraftOnlyInDevelopment, whereSlugEqualsParam(params.slug) )
I'd prefer the first approach generally. I think creating operators is beneficial only if you'd use them multiple times.
What's the design vision with regards to this?
or are we expected to do :