fulltext-engine
fulltext-engine copied to clipboard
Using with multilevel
Right now it's kind of tricky to use this with multilevel because of the methods on the query object. You need to get manually add them, but nesting objects with level-manifest becomes a kind of code-smell. I just started on this so maybe you have done this before and have a better way to do it?
/cc @juliangruber
level-manifest supports nested objects, what exactly is the code-smell?
So i start off with a list of sublevels that I want to create and then iteratively add them to the db object.
db[name] = db.sublevel(name)
levelQuery(db[name])
db[name].query.use(fulltextEngine())
...then I add the methods for each of the sublevels.
db.methods[name] = {
type: 'object',
methods: createManifest(db[name]).methods
}
the potentially smelly part is where I need to nest another object for the query member of levelQuery and another member for the methods that are attached to that.
db.methods[name].methods.query = {
type: 'object',
methods: { // ...
}
}
But maybe there is a cleaner way to build the manifest object.
Actually, maybe this shouldn't be an issue because you don't actually need all the methods on query to be exposed from multilevel. Maybe just adding query as a readable type is good enough
I haven't tried to use this with multilevel, but multilevel should support nested objects, though I haven't actually tried to get it working myself. Let me know how you go!
On Thu, Apr 3, 2014 at 7:35 AM, Paolo Fragomeni [email protected]:
Actually, maybe this shouldn't be an issue because you don't actually need all the methods on query to be exposed from multilevel. Maybe just adding query as a readable type is good enough
Reply to this email directly or view it on GitHubhttps://github.com/eugeneware/fulltext-engine/issues/2#issuecomment-39380087 .
Eugene Ware Chief Executive Officer
Phone: +61 3 9955 7041 Email: [email protected] Twitter: @EugeneWare http://twitter.com/EugeneWare
Noble Samurai Pty Ltd Level 1, 234 Whitehorse Rd Nunawading, Victoria, 3131, Australia
noblesamurai.com http://www.noblesamurai.com/ | eugeneware.com | facebook.com/Eugene.S.Ware http://www.facebook.com/Eugene.S.Ware
so i just end up doing this per sublevel,
db[name] = levelQuery(db[name])
db[name].query.use(fulltextEngine())
db[name].methods['search'] = { type: 'readable' }
db[name].search = db[name].query
not sure if that's the most efficient way of adding it, but I also have less than 20 sub-levels so I think its fine for now. I'll continue to improve it and possibly do a blog post.
cool that looks good!
Awesome. Glad you found a work around!
On Fri, Apr 4, 2014 at 2:26 AM, Julian Gruber [email protected]:
cool that looks good!
Reply to this email directly or view it on GitHubhttps://github.com/eugeneware/fulltext-engine/issues/2#issuecomment-39465042 .
Eugene Ware Chief Executive Officer
Phone: +61 3 9955 7041 Email: [email protected] Twitter: @EugeneWare http://twitter.com/EugeneWare
Noble Samurai Pty Ltd Level 1, 234 Whitehorse Rd Nunawading, Victoria, 3131, Australia
noblesamurai.com http://www.noblesamurai.com/ | eugeneware.com | facebook.com/Eugene.S.Ware http://www.facebook.com/Eugene.S.Ware
@juliangruber @hij1nx I just realized all the cool nested object stuff in multilevel/level-manifest hasn't been published in the latest multilevel version.
@juliangruber Could you do an npm publish of what's in master?
seems to break with multilevel 6.0.0.
@hij1nx can you post a reproducable thing, maybe using requirebin?
@juliangruber yes, but i'll need to jump though a lot of hoops to do it so first im going to try to figure out why i broke.
@hij1nx @juliangruber I've done a revamp of all the level-queryengine modules to make them use all the latest and greatest modules. I've also added multilevel tests that are currently passing. You may need to install the latest version though (I've bumped the major version number just to be safe).
If it's still failing, please shoot me a failing test and I'll take a look.
awesome!