Thanks Alan, That layout makes a lot of sense.
Cheers On Thursday, 4 August 2016 17:10:45 UTC+1, Alan Plum wrote: > > Hi Andrei, > > there is no support for "registered" queries but ArangoDB has an optional > query cache: > https://docs.arangodb.com/3.0/AQL/ExecutionAndPerformance/QueryCache.html > > There is no official recommendation for where to put your queries but > personally I just wrap them in functions and store those functions in > separate modules. > > For example, a service for managing training courses might have a layout > looking like this: > > /index.js <- imports and mounts the router from require("./routes") > /routes > /routes/index.js <- imports all the other routers > /routes/admin.js <- endpoints that require admin access > /routes/restricted.js <- endpoints that require a login but not admin > access > /routes/public.js <- endpoints that are public to everyone > /queries > /queries/availableCourses.js <- a query returning all courses available to > a user > /queries/exams/getActive.js <- a query returning active exams for a user > /queries/exams/summary.js <- a query returning a summary for a user's exams > /queries/exams/report.js <- a query returning an overview of exam results > for all users > > And the router files would then just import the queries they need and use > them like any other function. > > Note that Foxx Queries can be trivially replaced with ordinary functions > using the `aql` template string handler. Check out the relevant chapter in > the documentation: > > https://docs.arangodb.com/3.0/Manual/Foxx/Migrating2x/Queries.html > > > Cheers, > > Alan > > On Tuesday, 26 July 2016 12:14:39 UTC+2, Andrei wrote: >> >> Hi, >> >> Prior to the 3.x release, I stored AQL queries against the repository >> using Foxx.Repository.extend and Foxx.createQuery. >> >> This had the advantage that I could reuse the queries across controllers, >> and provided a good place to store AQL so that it didn't clutter >> controllers. >> >> Now repositories are obsolete, do you have any recommendations on the >> best (and neatest) place to put AQL so it can be reused? >> >> Also, are there any plans to be able to "register" queries, so they can >> be pre processed / optimised? >> >> Kind Regards, >> >> Andrei >> > -- You received this message because you are subscribed to the Google Groups "ArangoDB" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
