Developus
Developus

Reputation: 1462

How to create view for selected index in Couchbase?

I have created an index on my field login:

CREATE INDEX ix_login_date ON mybucket (login);

I can use it and select fields I want:

SELECT u.*
FROM mybucket u
WHERE DATE_DIFF_STR(NOW_STR(), login, 'day') > 30;

My question is - how can I create a View which will use this index to find docs I want? I need to use View in API, but I have no idea how it should looks like. I want this View to do same thing as above SELECT query. Is it possible?

Upvotes: 1

Views: 26

Answers (1)

Johan Larson
Johan Larson

Reputation: 1890

You can do this:

CREATE INDEX ix_login_date ON mybucket (login) USING VIEW

Upvotes: 2

Related Questions