Provides easy access to elasticsearch
from Sails.js & Waterline.
To install this adapter, run:
$ npm install waterline-elasticsearch
var orm = new Waterline();
var config = {
adapters: {
elasticsearch: require('waterline-elasticsearch')
},
connections: {
myLocalElasticsearch: {
adapter: 'elasticsearch',
host: 'localhost',
port: 9200,
log: 'warning',
index: '<index to use>'
}
}
};
var createModel = function(orm, identity, connection, tablename) {
console.log("Using connection: " + connection + " for object: " + identity);
var obj = Waterline.Collection.extend({
identity: identity,
tableName: tablename ? tablename : identity + 's',
connection: connection,
attributes: {
id: {
type: 'integer',
primaryKey: true,
// required: true,
index: true
}
}
});
orm.loadCollection(obj);
}
createModel(orm, 'note', 'myLocalElasticsearch', 'notes');
orm.initialize(config, function(err, models) {
if (err) throw err;
app.models = models.collections;
});
app.models[note].findOne({
id: id
}).exec(function(err, model) {
if (err) console.log(err);
console.log(model);
});
This adapter exposes the following methods:
- Status
- Done
- Status
- Done
- Status
- Done
- Status
- Done
- Status
- Done