• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Rob Spoor
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Carey Brown
Bartenders:

SpringBoot Reactive with Couchbase

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am a bit new with Spring Boot.
I have setup a Couchbase database and created a couple of buckets one which is called Resources

I can have setup a couple of endpoints and can connect to the database through a repository

The repository is as shown: Also I have attached the java files

I can retrieve an individual resource with it's resource id and everything works fine. However, I cannot get the findAll to work.
In addition, I cannot post a resource and have it saved.

Any ideas ?

I have zipped the src folder
Also the resource bucket has been configured with a PRIMARY index and another index on resourceId

I am confused why I get no error just an empty list when I do a findAll
Is there anything I need to configure in couchbase ?


Here is my code snippets

@RestController
class UserRestService {

private static final int String = 0;
UserRepository userRepository;


public UserRestService(UserRepository userRepository) {
super();
this.userRepository = userRepository;
}

@GetMapping( value="/users")
// ResponseEntity< List<User>>
Flux<User> allUsers() {

return this.userRepository.findAll();
}

@GetMapping( value="/users/{resourceId}")
          Mono< User> aUser(@PathVariable(value  = "resourceId", required = false ) String resourceId ) {
return this.userRepository.findById(resourceId );
}

@PostMapping( value="/users/{resourceId}")
ResponseEntity< String > postUser( @RequestBody User theUser) {

this.userRepository.save(theUser);
return ResponseEntity.status(HttpStatus.CREATED).build();

}



@Document
class User {
@NonNull
@Id
String id;

@NonNull
@Field
String role;

@Override
public String toString() {
return "User [id=" + id + ", role=" + role + ", organizationId=" + organizationId + "]";
}

@NonNull
@Field
String organizationId;

public String getId() {
return id;
}

public void setId(String id) {
this.id = id;
}

public String getRole() {
return role;
}

public void setRole(String role) {
this.role = role;
}

public String getOrganizationId() {
return organizationId;
}

public void setOrganizationId(String organizationId) {
this.organizationId = organizationId;
}
}



@Repository
public interface UserRepository
extends ReactiveCrudRepository<User, String> {
Flux< User > findAll();


}









 
reply
    Bookmark Topic Watch Topic
  • New Topic