learn
Using Props in Vue Router
· ☕ 2 min read
Vue router can pass props to the view on invocation. This can be super useful when same views cater to different contexts, and the context is known at the time of clicking URL. Vue router just catches the context and passes it on to the view. For example: if you want to show “My Todos” to all users, and “All Todos” to administrators.

Authentication in Vue Router
· ☕ 3 min read
Vue router has a simple job - receive client-side requests and invoke the view that needs to be rendered in the browser. That is also a powerful job. Typically, this is what you see in a Vue router - 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 // client/router.

Persistent Storage in VueJS
· ☕ 3 min read
VueJS is massively useful tool. And, I love churning out SFCs like there’s no tomorrow. Vue helps us provide a super user experience. Combine it with Vuetify, Buefy and the like, and you have an application that is loved by all. Except, when the user hits F5 in the browser.

Using Lucid vs. Database Raw in AdonisJS
· ☕ 2 min read
Lucid ORM, the official ORM of AdonisJS, is based on knex.js. It is one of the friendlier ORMs that provides the ease of using a readable syntax along with a better performance than some of the feature-heavy ORMs. But, I have been recently torn between using one or the other.

Manage incremental changes to database in AdonisJS
· ☕ 2 min read
Use database migration utilities in Adonis to its complete potential. Carry out incremental updates - may it be a new table, or changes to existing table using distinct migration files that are version controlled. You have a beautiful Todo application that has a todos table with the following columns: description status end_date Now, let’s say our users ask for a new field called planned_end_date.

Handle Creation of Single or Multiple Records in AdonisJS
· ☕ 2 min read
Support creation of a single record or a group of records using same business logic and in the same controller in AdonisJS. Typically you create the following controller to handle record creation - 1 2 3 4 5 6 // TodoController.js async create({ request, auth }) { const data = request.

Custom Configuration Parameters in AdonisJS
· ☕ 1 min read
AdonisJS stores its configuration values in config folder in root. For e.g. you will set database environment values in database.js, authentication params in auth.js and so on. You can update or set new configuration parameters required by your application in those files. You could also create a new configuration file for your application variables and refer to those values from services, controllers, or from any place where it makes sense.

Pagination in AdonisJS
· ☕ 3 min read
AdonisJS provides a standard way to handle pagination and query only a pre-defined number of records in your query result. A typical controller without any pagination looks like the below - 1 2 3 4 5 6 7 8 // TodoController.js const Todo = use("App/Models/Todo"); class TodoController { async index({ request, response, view }) { return await Todo.

Role-based Access to Routes in AdonisJS
· ☕ 2 min read
AdonisJS provides a standard way to define a middleware and enable access to routes based on defined validation rules. This middleware is leveraged to allow role-based access to routes. Your start | routes.js file will have something akin to below - 1 2 3 4 5 const Route = use("Route"); Route.

Change Date Formats in AdonisJS
· ☕ 3 min read
AdonisJS internally uses moment.js and processes all dates in YYYY-MM-DD format. The format, being an international standard, should have been the standard everywhere. Since it is not, let us see how we can modify the date format. Consider an example - Todo has a end_date field against every record. Your model will look like the below -

Return Related Record Post Saving Record in AdonisJS
· ☕ 1 min read
AdonisJS automatically returns the base/parent record to the caller from the controller. However, you may have to custom code all of one statement to return a related record after the parent record is committed to the database. Consider an example - 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 // TodoController.

Simple Role-based Validation Techniques for AdonisJS
· ☕ 2 min read
AdonisJS does not provide an access control list (ACL) feature out of the box. Here’s are a few simple ways to provide the right access to the right user when using AdonisJS. Use ACL plugins There are two plugins available for AdonisJS - Adonis ACL Advanced Adonis ACL The usage is pretty simple.

Custom Exceptions in AdonisJS
· ☕ 2 min read
AdonisJS provides streamlined ways to raise exceptions in your controller or service code, and raise them in a controlled way to the caller. To create a custom exception - 1 adonis make:exception RecordNotFoundException This will create - 1 √ create app\Exceptions\RecordNotFoundException.js Edit the exception to introduce your own errors.