mquery icon indicating copy to clipboard operation
mquery copied to clipboard

browser compatible

Open aheckmann opened this issue 12 years ago • 8 comments

aheckmann avatar Apr 23 '13 01:04 aheckmann

To make this easier, I think the actual querying should be left out of this repo (remove the mongodb dependency) and allow passing any object that implements the collection interface or even just having this library simply generate valid query objects. For example I have my own fork that returns an object with the final query/updateDoc/options, which I then pass to a component that converts simple queries to RESTful urls to use client-side

tarqd avatar Aug 18 '13 13:08 tarqd

sounds good to me

aheckmann avatar Aug 19 '13 18:08 aheckmann

Do you think it'd be better to return a query object or just have it so you pass a collection object to the library?

tarqd avatar Aug 20 '13 02:08 tarqd

that's actually how it works today. we just wrap the passed collection in a compatibility layer. We should break the layer out and define it so its easy to create other compat layers.

aheckmann avatar Aug 20 '13 16:08 aheckmann

so you need access to the fields/options etc? we could expose that.

aheckmann avatar Aug 20 '13 16:08 aheckmann

Right now if you override mquery.Collection we'll use that instead but it must conform to the mquery collection API. take a look at lib/collection

aheckmann avatar Aug 20 '13 16:08 aheckmann

Only problem with a browser version is lib/utils.js currently requires mongodb (for ReadPref and ObjectId). I'd say have the collection define it (NodeCollection.ObjectId or NodeCollection.Types.ObjectId)

That way you can just define polyfills for those types for the browser/mongoshell

tarqd avatar Aug 20 '13 17:08 tarqd

that sounds good for now. maybe nice to provide a clean env abstraction which provides the collection,objectid,readpref etc.

aheckmann avatar Aug 20 '13 22:08 aheckmann