I have something roughly like this:
# define a function to operate on `Post` queries
Post.defineStatic "postListing", (options) ->
query = @
query = query.orderBy args
if options.condition
query = query.filter args
query = query.splice args
query = query.getJoin args
# return the in-progress query
query
I wanted to do it like this, but the library I'm using won't let me:
Post.defineStatic "postListing", (options) -> @orderBy args if options.condition @filter args @splice args @getJoin args # the above line would implicitly return the query
Is there a way to write the first snippet in a cleaner way, maybe with es6 generators? I've tried using a shorter variable name like q
but that just makes it messy.