Nice one!
On 06/12/2017 01:49 PM, Glynn Bird wrote:
I thought I'd share a small JavaScript library I wrote the other day: https://www.npmjs.com/package/sqltomango It's mission is very simple: it takes an SQL query e.g. SELECT _id, age, breed FROM dogs WHERE owner = 'glynn' OR (name='towser' AND colour='white') ORDER BY age DESC LIMIT 500,1500 parses it and returns the CouchDB Mango equivalent: {"fields":["_id","age","breed"],"selector":{"$or":[{"owner":{"$eq":"glynn"}},{"$and":[{"name":{"$eq":"towser"}},{"colour":{"$eq":"white"}}]}]},"sort":[{"age":"desc"}],"limit":1500,"skip":500} It doesn't magically make CouchDB support joins, unions, transactions etc, but it is useful as a means of translating queries for new users. I wrote it for a blog post for my developer advocacy work, but it's free, open-source (Apache license obviously) and ready to go for anyone else to build with or to extend. Glynn
