Skip to content

Commit

Permalink
refactor: rename demos to be consistent with the Redis OM branding
Browse files Browse the repository at this point in the history
  • Loading branch information
bsbodden committed Nov 29, 2021
1 parent c731d4f commit 7a48cbf
Show file tree
Hide file tree
Showing 47 changed files with 114 additions and 891 deletions.
53 changes: 33 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,22 @@ This **preview** release provides all of SDRs capabilities plus:
Here is a quick teaser of an application using Redis OM Spring to map a Spring Data model
using a RedisJSON document.

### 🚀 Launch Redis

Redis OM Spring relies on the power of the [RediSearch][redisearch-url] and [RedisJSON][redis-json-url] modules.
We have provided a docker compose YAML file for you to quickly get started. To launch the docker compose application, on the command line (or via Docker Desktop), clone this repository and run (from the root folder):

```bash
docker compose up
```

### The SpringBoot App

Use the `@EnableRedisDocumentRepositories` annotation to scan for `@Document` annotated Spring models,
Inject repositories beans implementing `RedisDocumentRepository` which you can use for CRUD operations and custom queries (all by declaring Spring Data Query Interfaces):

```java
package com.redis.documents;
package com.redis.om.documents;

import java.util.Set;

Expand All @@ -80,24 +89,24 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.geo.Point;

import com.redis.documents.domain.Company;
import com.redis.documents.domain.Person;
import com.redis.documents.repositories.CompanyRepository;
import com.redis.documents.repositories.PersonRepository;
import com.redis.spring.annotations.EnableRedisDocumentRepositories;
import com.redis.om.documents.domain.Company;
import com.redis.om.documents.repositories.CompanyRepository;

@SpringBootApplication
@Configuration
@EnableRedisDocumentRepositories(basePackages = "com.redis.documents.*")
public class RdsDocumentsApplication {
@EnableRedisDocumentRepositories(basePackages = "com.redis.om.documents.*")
public class RomsDocumentsApplication {

@Autowired
CompanyRepository companyRepo;

@Bean
CommandLineRunner loadTestData() {
return args -> {
// remove all companies
companyRepo.deleteAll();

// Create a couple of `Company` domain entities
Company redis = Company.of(
"Redis", "https://redis.com", new Point(-122.066540, 37.377690), 526, 2011 //
);
Expand All @@ -107,11 +116,15 @@ public class RdsDocumentsApplication {
"Microsoft", "https://microsoft.com", new Point(-122.124500, 47.640160), 182268, 1975 //
);
microsoft.setTags(Set.of("innovative", "reliable"));

// save companies to the database
companyRepo.save(redis);
companyRepo.save(microsoft);
};
}

public static void main(String[] args) {
SpringApplication.run(RdsDocumentsApplication.class, args);
SpringApplication.run(RomsDocumentsApplication.class, args);
}
}
```
Expand All @@ -122,13 +135,14 @@ Like many other Spring Data projects, an annotation at the class level determine
of the class are persisted. Redis OM Spring provides the `@Document` annotation to persist models as JSON documents using RedisJSON:

```java
package com.redis.documents;
package com.redis.om.documents.domain;

import java.util.HashSet;
import java.util.Set;
import org.springframework.data.annotation.Id;
import org.springframework.data.geo.Point;
import com.redis.spring.annotations.*;
import com.redis.om.spring.annotations.Document;
import com.redis.om.spring.annotations.Searchable;
import lombok.*;

@Data
Expand Down Expand Up @@ -159,18 +173,17 @@ that extends `RedisDocumentRepository` that takes the domain class to manage as
Declare query methods on the interface. You can both, expose CRUD methods or create declarations for complex queries that Redis OM Spring will fullfil at runtime:

```java
package com.redis.documents.repositories;
package com.redis.om.documents.repositories;

import java.util.Optional;
import java.util.Set;
import java.util.*;

import org.springframework.data.geo.Distance;
import org.springframework.data.geo.Point;
import org.springframework.data.repository.query.Param;

import com.redis.documents.domain.Company;
import com.redis.spring.annotations.Query;
import com.redis.spring.repository.RedisDocumentRepository;
import com.redis.om.documents.domain.Company;
import com.redis.om.spring.annotations.Query;
import com.redis.om.spring.repository.RedisDocumentRepository;

public interface CompanyRepository extends RedisDocumentRepository<Company, String> {
// find one by property
Expand Down Expand Up @@ -221,12 +234,12 @@ The Redis OM documentation is available [here](docs/index.md).

### Basic JSON Mapping and Querying

- **rds-documents**:
- **roms-documents**:
- Simple API example of `@Document` mapping, Spring Repositories and Querying.
- Run with `./mvnw install -Dmaven.test.skip && ./mvnw spring-boot:run -pl demos/rds-documents`
- Run with `./mvnw install -Dmaven.test.skip && ./mvnw spring-boot:run -pl demos/roms-documents`
- **rds-hashes**:
- Simple API example of `@RedisHash`, enhanced secondary indices and querying.
- Run with `./mvnw install -Dmaven.test.skip && ./mvnw spring-boot:run -pl demos/rds-hashes`
- Run with `./mvnw install -Dmaven.test.skip && ./mvnw spring-boot:run -pl demos/roms-hashes`

## ⛏️ Troubleshooting

Expand Down
Binary file not shown.
95 changes: 0 additions & 95 deletions demos/rds-documents/bin/pom.xml

This file was deleted.

Binary file not shown.
Binary file not shown.
33 changes: 0 additions & 33 deletions demos/rds-hashes/.gitignore

This file was deleted.

Binary file removed demos/rds-hashes/.mvn/wrapper/maven-wrapper.jar
Binary file not shown.
2 changes: 0 additions & 2 deletions demos/rds-hashes/.mvn/wrapper/maven-wrapper.properties

This file was deleted.

Loading

0 comments on commit 7a48cbf

Please sign in to comment.