A proof of concept MongoDB clone built on Postgres
Mongolike is an experimental MongoDB clone being built on top of PLV8 and Postgres.
Visit http://code.google.com/p/plv8js/wiki/PLV8 and follow the build instructions.
The easy way to install is to use node.js.
$ npm install -g mongolike
$ mongolike-install -d yourdb$ for file in sql/*.sql; do psql yourdb = j) continue;
c1 = reduced.data[i];
c2 = reduced.data[j];
d = Math.sqrt((c1.lat-c2.lat)*(c1.lat-c2.lat)+(c1.lon-c2.lon)*(c1.lon-c2.lon));
if (d 0) {
min_dist = d;
city1 = c1;
city2 = c2;
}
}
}
return {
\"city1\": city1.city,
\"city2\": city2.city,
\"dist\": min_dist
};
}" }');Creates a new index on a collection.
Example:
SELECT ensureIndex('test', '{ "foo", "bar" }', '{ "unique": true }');Removes an index from a collection by name.
Example:
SELECT removeIndex('test', 'idx_col_woo_foo');Removes an index from a collection by terms.
NOTE in order to remove an index with terms you MUST cast the query due to how Postgres handles JSON.
Example:
SELECT removeIndex('test', '{ "foo", "bar" }'::json);Retrieves all indexes for a given collection.
Example:
SELECT getIndexes('test');I have included a modest amount of data for testing and benchmarking, both for Postgres and for MongoDB (1,706,873 rows).
Importing into Postgres:
$ psql yourdb < data/cities.sqlThis will create the collection and save() all of the data.
Importing into MongoDB
$ mongoimport --collection cities --type csv --headerline --file data/cities.csv --db yourdbFollow along at http://legitimatesounding.com/blog/
No open issues yet, or sync has not completed.