Compare commits
2 Commits
labs/manua
...
issue/SO-6
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
35214b9dd5 | ||
|
|
6013bc8687 |
2
pom.xml
2
pom.xml
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
<groupId>org.springframework.data</groupId>
|
<groupId>org.springframework.data</groupId>
|
||||||
<artifactId>spring-data-mongodb-parent</artifactId>
|
<artifactId>spring-data-mongodb-parent</artifactId>
|
||||||
<version>3.0.0.BUILD-SNAPSHOT</version>
|
<version>3.0.0.SO-60250019-SNAPSHOT</version>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
<name>Spring Data MongoDB</name>
|
<name>Spring Data MongoDB</name>
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springframework.data</groupId>
|
<groupId>org.springframework.data</groupId>
|
||||||
<artifactId>spring-data-mongodb-parent</artifactId>
|
<artifactId>spring-data-mongodb-parent</artifactId>
|
||||||
<version>3.0.0.BUILD-SNAPSHOT</version>
|
<version>3.0.0.SO-60250019-SNAPSHOT</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springframework.data</groupId>
|
<groupId>org.springframework.data</groupId>
|
||||||
<artifactId>spring-data-mongodb-parent</artifactId>
|
<artifactId>spring-data-mongodb-parent</artifactId>
|
||||||
<version>3.0.0.BUILD-SNAPSHOT</version>
|
<version>3.0.0.SO-60250019-SNAPSHOT</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springframework.data</groupId>
|
<groupId>org.springframework.data</groupId>
|
||||||
<artifactId>spring-data-mongodb-parent</artifactId>
|
<artifactId>spring-data-mongodb-parent</artifactId>
|
||||||
<version>3.0.0.BUILD-SNAPSHOT</version>
|
<version>3.0.0.SO-60250019-SNAPSHOT</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
|
|||||||
@@ -4272,4 +4272,46 @@ public class MongoTemplateTests {
|
|||||||
String value;
|
String value;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Data
|
||||||
|
static class UserActivity {
|
||||||
|
String id;
|
||||||
|
String userId;
|
||||||
|
Likes likes;
|
||||||
|
}
|
||||||
|
|
||||||
|
static class Likes {
|
||||||
|
List<Video> videos;
|
||||||
|
}
|
||||||
|
|
||||||
|
static class Video {
|
||||||
|
String id;
|
||||||
|
String title;
|
||||||
|
|
||||||
|
Video(String id, String title) {
|
||||||
|
this.id = id;
|
||||||
|
this.title = title;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void removeVideoLike() {
|
||||||
|
|
||||||
|
template.dropCollection(UserActivity.class);
|
||||||
|
|
||||||
|
UserActivity userActivity = new UserActivity();
|
||||||
|
userActivity.userId = "123";
|
||||||
|
userActivity.likes = new Likes();
|
||||||
|
userActivity.likes.videos = new ArrayList<>();
|
||||||
|
userActivity.likes.videos.add(new Video("abc", "test"));
|
||||||
|
|
||||||
|
template.save(userActivity);
|
||||||
|
|
||||||
|
Query queryUser = Query.query( Criteria.where("userId").is("123") );
|
||||||
|
Query queryVideo = Query.query( Criteria.where("id").is("abc") );
|
||||||
|
Update update = new Update().pull("likes.videos", queryVideo );
|
||||||
|
|
||||||
|
UpdateResult result = template.updateFirst(queryUser, update, UserActivity.class);
|
||||||
|
assertThat(result.getModifiedCount()).isOne();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user