colinskow / superlogin

Powerful authentication for APIs and single page apps using the CouchDB ecosystem which supports a variety of providers.
MIT License
370 stars 116 forks source link

Sample Mango query designDoc #164

Open markamccorkle opened 7 years ago

markamccorkle commented 7 years ago

I've successfully created .js based designDocs for superlogin but am having trouble using query indexes. Is this supported? For instance, how would we use a design doc for a simple index which Fauxton creates?

https://pouchdb.com/guides/mango-queries.html

{
  "_id": "_design/1",
  "language": "query",
  "views": {
    "2": {
      "map": {
        "fields": {
          "date": "asc"
        }
      },
      "reduce": "_count",
      "options": {
        "def": {
          "fields": [
            "date"
          ]
        }
      }
    }
  }
}
peteruithoven commented 7 years ago

I feel like the following question of mine asks the same question or maybe is related? https://github.com/colinskow/superlogin/issues/116

markamccorkle commented 7 years ago

Yes, I've looked over your question and that's definitely the main reason I can't just simply create an index when the user logs in using pouch therefore I assume we have to do this from a designDoc or add more lenient db security? The only problem is I can't find a good example of a design doc where superlogin accepts query as the language. If we can do the same thing in js I'd gladly go that route. The only example I see is the user-design.js doc.

peteruithoven commented 7 years ago

Superlogin uses pouch-seed-design. I don't see any mention of support for the query language. I think we might need to start an issue and/or pull request there.

For examples of design docs I would check the CouchDB documentation: http://docs.couchdb.org/en/2.0.0/intro/tour.html?highlight=design%20doc#running-a-query-using-mapreduce http://docs.couchdb.org/en/2.0.0/couchapp/views/intro.html?highlight=design%20docs

If I understand it correctly the new query language only makes it easier, it doesn't add functionality?