How to read records from couchdb view

I’m trying without success to get my documents from my couchdb view I’ve created.
Its works when I’m accessing the view through couchdb itself: _design/{myDesign}/_view/{viewName}

But I cant get the same with dreamfactory

/_table/{tableName}/_design/{myDesign}/_view/{viewName}

please help me :smile:
Thanks in advance

Are CouchDB views similar to SQL views? Because DreamFactory treats SQL views as tables, essentially.

https://wiki.dreamfactory.com/DreamFactory/Tutorials/Querying_SQL_views

What is happening? Error? Invalid data? No data found?
Give us more information about the problem.

I just don’t know and I didn’t find in the documentation any way to do that…

I know how to do it through couchdb… but not through dreamfactory

for example:
https://couchdb.com/newsfeed/_design/ordered/_view/byTime?limit=10&skip=0&descending=true

ordered is my design document
byTime is my view name

I tried to do the following:
https://df.enterprise.dreamfactory.com/api/v2/couch/_table/newsfeed?filter=_id=_design/ordered&api_key=***

but it says ‘SQL-like filters are not currently available for CouchDB’

It seems that some SQL are not avaiable to couchdb, like “filters” (I know, pretty obvious).

Did you try to do a Service that don’t need any filter or SQL, to show all record, just for test.
For example:
https://df.enterprise.dreamfactory.com/api/v2/couch/_table/newsfeed?api_key=**

This route will show all feeds.

I’d talk about Custom Script, but it would be the same.

That’s correct, SQL-like filters are not available for CouchDB. How familiar are you with CouchDB? This DB implements a query language in documents called views. So we didn’t attempt to implement SQL queries for CouchDB since Apache did it their own way in-house.

Tutorial on CouchDB views
Apache documentation on views

Search the forums also. This was already covered in this thread.

1 Like

Yes I can get all the records from df without any problem and yes I’m familiar with couchdb views…
Do you have an example how to fetch from a view using dreamfactory?
I didn’t find any on the web…

any ideas?


Someone please can help me with this???

Hello @Kfir_Peled, I also could not use the service couchdb, but did the following. As CouchDB natively exposes an API, I created a service type webservice in my DF.

Note: My couch does not have authentication, but if you have, added it to the headers tab.

In my case, optimizers is my database
I have a view called “resume” that is grouped in the “example” design

And for this scenario, my request to DF API is as follows:

http://192.168.254.251/rest/couch-api/_design/example/_view/resume?limit=10&app_name=my-api-key

Note: My DF is 1.9, and in DF 2, it is very similar

Best regards

1 Like

Thanks for your response !!!

I’m using DF2 and in my case I get the following error:

message: "Resource ‘_design’ not found for service ‘couch’."
code: 404

with a big stack of DF code

Maybe in DF2 they abstract that, try to call directly the resource:

http://192.168.254.251/rest/couch-api/resume?limit=10&app_name=my-api-key

or even with design in it:

http://192.168.254.251/rest/couch-api/example/resume?limit=10&app_name=my-api-key

Just a guess (a big one).

Hello, @Kfir_Peled

I could not make my couchdb work with api NoSQL. My solution was to set up the CouchDB in a webservice. Thus, the available resource are precisely what CouchDB offers natively via Rest API. The advantage is that with DF you can restrict the service to a role and use the user’s session without exposing directly to Rest native API of your CouchDB.

1 - Create service type Webservice to connect native CouchDB Rest API

2 - Configure CouchDB HTTP dsn in created Webservice

3 - Example of use with views and filters

Links:

Apache CouchDB Querying Options DOC: https://goo.gl/4DJTTk
DF2 API Common Headers & Parameters : http://goo.gl/tPlnW9
Postman (my API rest client tool used in this example): https://www.getpostman.com

I apologize if I was confused in my first response

Best regards.

1 Like