Improve couchbase support

Expose an `auto-index` property that controls if views and indexes
should be created automatically.

Update the sample so that it uses this new property, lowering the manual
steps to make it working on a vanilla couchbase server.

See gh-3498
This commit is contained in:
Stephane Nicoll
2016-02-16 11:34:19 +01:00
parent ed04a5b12e
commit 64a5cad09a
10 changed files with 102 additions and 34 deletions

View File

@@ -35,18 +35,19 @@ public class SampleCouchbaseApplication implements CommandLineRunner {
@Override
public void run(String... args) throws Exception {
saveUsers();
this.userRepository.deleteAll();
User user = saveUser();
System.out.println(this.userRepository.findAll());
System.out.println(this.userRepository.findOne(user.getId()));
}
private void saveUsers() {
private User saveUser() {
User user = new User();
user.setId(UUID.randomUUID().toString());
user.setFirstName("Alice");
user.setLastName("Smith");
this.userRepository.save(user);
return this.userRepository.save(user);
}
}

View File

@@ -16,8 +16,10 @@
package sample.data.couchbase;
import org.springframework.data.couchbase.core.query.ViewIndexed;
import org.springframework.data.couchbase.repository.CouchbaseRepository;
@ViewIndexed(designDoc = "user", viewName = "all")
public interface UserRepository extends CouchbaseRepository<User, String> {
}