fulltext-engine icon indicating copy to clipboard operation
fulltext-engine copied to clipboard

Using with multilevel

Open heapwolf opened this issue 11 years ago • 13 comments

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

heapwolf avatar Apr 02 '14 19:04 heapwolf

level-manifest supports nested objects, what exactly is the code-smell?

juliangruber avatar Apr 02 '14 19:04 juliangruber

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.

heapwolf avatar Apr 02 '14 20:04 heapwolf

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

heapwolf avatar Apr 02 '14 20:04 heapwolf

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

eugeneware avatar Apr 02 '14 23:04 eugeneware

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.

heapwolf avatar Apr 03 '14 14:04 heapwolf

cool that looks good!

juliangruber avatar Apr 03 '14 15:04 juliangruber

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

eugeneware avatar Apr 04 '14 13:04 eugeneware

@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?

eugeneware avatar Apr 14 '14 05:04 eugeneware

seems to break with multilevel 6.0.0.

heapwolf avatar May 12 '14 16:05 heapwolf

@hij1nx can you post a reproducable thing, maybe using requirebin?

juliangruber avatar May 12 '14 17:05 juliangruber

@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.

heapwolf avatar May 12 '14 17:05 heapwolf

@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.

eugeneware avatar May 13 '14 13:05 eugeneware

awesome!

juliangruber avatar May 13 '14 14:05 juliangruber