![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
@brainnit/adonisjs-scout
Advanced tools
Adonis Scout provides a driver based solution for searching your Lucid models, just like Laravel Scout.
Adonis Scout provides a driver based solution for searching your Lucid models, heavily inspired by Laravel Scout and Scout Elasticsearch Driver.
Use npm or yarn to install the package:
npm -i @brainnit/adonisjs-scout
yarn add @brainnit/adonisjs-scout
Add Scout to the list of service providers at start/app.js
:
const providers = [
// ...
'@brainnit/adonisjs-scout/providers/ScoutProvider'
];
Copy config/index.js
to your app config folder and name it scout.js
. Don't forget to setup your environment variables.
Add @provider:Searchable
trait to your models and define only the methods you want to override to change default behaviour:
/** @type {typeof import('@adonisjs/lucid/src/Lucid/Model')} */
const Model = use('Model');
class User extends Model {
static get traits () {
return ['@provider:Searchable']
}
}
module.exports = Users
A search rule is a class that describes how a search query will be executed and allow you to build complex and reusable searches with the support of the Builder
instance.
To create a search rule use the following command:
adonis make:searchableRule MySearchRule
In the file app/Models/SearchableRules/MySearchRule.js you will find a class definition:
'use strict'
/** @type {typeof import('@brainnit/adonisjs-scout/src/SearchRule')} */
const SearchRule = use('Scout/SearchRule')
class MySearchRule extends SearchRule {
buildQuery () {
return {
'must': {
'match': {
'name': this.builder.query
}
}
}
}
}
module.exports = MySearchRule
To tell Scout about what search rules your model supports, just add the following method:
/**
* Specify what search rules the model supports.
*
* The return value(s) must always class namespaces that will be
* resolved by IoC Container.
*
* @static
*
* @method searchableRules
*
* @return {Array|String} ES6 Class
*/
static searchableRules () {
return ['App/Models/SearchRules/MySearchRule']
}
What else? Please open an Issue for suggestions.
FAQs
Adonis Scout provides a driver based solution for searching your Lucid models, just like Laravel Scout.
The npm package @brainnit/adonisjs-scout receives a total of 1 weekly downloads. As such, @brainnit/adonisjs-scout popularity was classified as not popular.
We found that @brainnit/adonisjs-scout demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.