I am trying to retrieve only ids from bucket using n1ql @query using spring couchbase.
or alos looking to delete the couchbase item based on attribute. similar to
delete from sample where headId = 234;
1 Like
Hi @raradhi,
You may want to ask this in the Java SDK forum: Java SDK - Couchbase Forums, I’m sure @subhashni can help.
In the case that Spring doesn’t support this directly, you can always fall back to using the Couchbase SDK directly and execute N1QL queries (just don’t forget to parameterize to avoid injection attacks).
-Matt
Indeed if you want to stick to using Spring Data repositories, it will keep trying to map any query you do to an entity.
If you do something like:
interface UserRepository extends CouchbasePagingAndSortingRepository<User, String>{
@Query("select meta().id as identifier, meta().id as _ID, meta().cas as _CAS FROM #{#n1ql.bucket} WHERE #{#n1ql.filter}")
List<User> findUserIds();
You get user with just fields from your select that are not _ID and _CAS.
But since you are using Spring Data, as @matthew.groves said you can use the SDK directly. It’s injectable as a Spring Bean.
1 Like
thanks for the response.
worked great. thanks.