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:
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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> {
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user