JerrySievert / mongolike

A proof of concept MongoDB clone built on Postgres
MIT License
387 stars 24 forks source link

Trying to test this locally #1

Closed e1ven closed 11 years ago

e1ven commented 11 years ago

Thanks for writing this, it's a very cool idea! ;)

I'm trying to test locally, and ran into some problems-

I was getting a "DETAIL: undefined() LINE 0: [object Object]" error when trying to save any javascript, including the .sql file you included.

It looks like this is because it's treating it as an object, not a JS string. I was able to get past this, by replacing

var obj = JSON.parse(data);

with

var obj = JSON.parse(JSON.stringify(data));

After making this change I was able to import as expected.

I am still having issues querying, however.

hostname=# SELECT find('cities', '{ "Country": "zw" }'); ERROR: type "undefined" does not exist hostname=#

ERROR: type "undefined" does not exist

I tried a few variations of typeof() instead of === or !==, but I wasn't able to get past this. Does this work on your machine as it is? Any idea what I might be doing wrong?

I'm on OSX 10.8.2, using psql 9.2.1, v8 3.9.24, plv8 from git.

Any advise would be appreciated.

JerrySievert commented 11 years ago

PLV8 made a breaking change with their last release - wherein they automatically did the JSON.parse() for you. If you want it working correctly right away, use my fork on my GitHub account:

http://github.com/jerrySievert/plv8

In the mean time, I'll look at updating all of the code to work with this breaking change.

e1ven commented 11 years ago

Thank you! Moving to your fork seems to work really well, and lets me keep playing with it.

The next thing I'm trying to figure is figuring out how to index. It looks like I can't directly index on the find() function, because it returns a set.

I don't think I can on the where function, because it's not immutable. Would I need to move upstream, and do the indexes on find_in_obj/etc?

Thank you once more for any and all help! -CPD

JerrySievert commented 11 years ago

I have ensure_index written, but have not pushed it. Will see what I can do when I get home tonight.

JerrySievert commented 11 years ago

Looks like I had ensureIndex() 90% of the way done, but not complete.

in the mean time, you can easily create indexes:

CREATE INDEX idx_cities ON col_cities (find_in_obj('data', 'address.state'));
e1ven commented 11 years ago

That's not that bad at all ;) Thanks!

I tested with your city data, and it appears to work really well. Awesome. Thank you

JerrySievert commented 11 years ago

no problem. if nothing else, this got me to touch a project that i hadn't quite finished. creating a branch tonight that works with the plv8 master.

JerrySievert commented 11 years ago

there is a branch beta that should allow you to work with the latest plv8 master.

going to close this for now