import de.juplo.kafka.chat.backend.domain.Message;
import lombok.*;
-import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.index.Indexed;
import org.springframework.data.mongodb.core.mapping.Document;
+import org.springframework.data.mongodb.core.mapping.Field;
import java.time.LocalDateTime;
import java.util.UUID;
-import java.util.regex.Matcher;
@AllArgsConstructor
@NoArgsConstructor
@Getter(AccessLevel.PACKAGE)
@Setter(AccessLevel.PACKAGE)
-@EqualsAndHashCode(of = { "user", "id" })
-@ToString(of = { "user", "id" })
+@EqualsAndHashCode(of = { "chatRoomId", "user", "id" })
+@ToString(of = { "chatRoomId", "user", "id" })
@Document
class MessageTo
{
private String chatRoomId;
@Indexed
private String user;
+ @Field("id")
@Indexed
private Long id;
@Indexed
{
- "_id": "5c73531c-6fc4-426c-adcb-afc5c140a0f7",
+ "_id": "a9e30ed3-7fd1-4eb9-b174-eebbf6ecfea9",
+ "shard": 0,
"name": "FOO",
- "messages": [
- {
- "_id": "peter--1",
- "serial": 0,
- "time": "2023-01-13T20:43:16.803382151",
- "text": "Hallo, ich heiße Peter!"
- },
- {
- "_id": "ute--1",
- "serial": 1,
- "time": "2023-01-13T20:43:16.804049969",
- "text": "Ich bin Ute..."
- },
- {
- "_id": "peter--2",
- "serial": 2,
- "time": "2023-01-13T20:43:16.804092782",
- "text": "Willst du mit mir gehen?"
- },
- {
- "_id": "klaus--1",
- "serial": 3,
- "time": "2023-01-13T20:43:16.804122604",
- "text": "Ja? Nein? Vielleicht??"
- }
- ],
"_class": "de.juplo.kafka.chat.backend.persistence.storage.mongodb.ChatRoomTo"
}
{
- "_id": "5c73531c-6fc4-426c-adcb-afc5c140a0f7",
- "name": "FOO",
- "messages": [
- {
- "_id": "peter--1",
- "serial": 0,
- "time": "2023-01-13T20:43:16.803382151",
- "text": "Hallo, ich heiße Peter!"
- },
+ "_id": {
+ "$oid": "64f7952cecf06d750cad4b9c"
+ },
+ "chatRoomId": "5c73531c-6fc4-426c-adcb-afc5c140a0f7",
+ "user": "peter",
+ "serial": {
+ "$numberLong": "0"
+ },
+ "time": "2023-01-13T20:43:16.803382151",
+ "text": "Hallo, ich heiße Peter!",
+ "_class": "de.juplo.kafka.chat.backend.persistence.storage.mongodb.MessageTo"
+}
+{
{
"_id": "ute--1",
"serial": 1,
"time": "2023-01-13T20:43:16.804049969",
"text": "Ich bin Ute..."
},
- {
- "_id": "peter--2",
- "serial": 2,
- "time": "2023-01-13T20:43:16.804092782",
- "text": "Willst du mit mir gehen?"
- },
- {
- "_id": "klaus--1",
- "serial": 3,
- "time": "2023-01-13T20:43:16.804122604",
- "text": "Ja? Nein? Vielleicht??"
- }
- ],
- "_class": "de.juplo.kafka.chat.backend.persistence.storage.mongodb.ChatRoomTo"
+ "_id": {
+ "$oid": "64f7952cecf06d750cad4b9d"
+ },
+ "chatRoomId": "5c73531c-6fc4-426c-adcb-afc5c140a0f7",
+ "user": "ute",
+ "id": {
+ "$numberLong": "1"
+ },
+ "serial": {
+ "$numberLong": "1"
+ },
+ "time": "2023-01-13T20:43:16.804049969",
+ "text": "Ich bin Ute...",
+ "_class": "de.juplo.kafka.chat.backend.persistence.storage.mongodb.MessageTo"
+}
+{
+ "_id": {
+ "$oid": "64f7952cecf06d750cad4b9e"
+ },
+ "chatRoomId": "5c73531c-6fc4-426c-adcb-afc5c140a0f7",
+ "user": "peter",
+ "id": {
+ "$numberLong": "2"
+ },
+ "serial": {
+ "$numberLong": "2"
+ },
+ "time": "2023-01-13T20:43:16.804092782",
+ "text": "Willst du mit mir gehen?",
+ "_class": "de.juplo.kafka.chat.backend.persistence.storage.mongodb.MessageTo"
+}
+{
+ "_id": {
+ "$oid": "64f7953ddf7a9063e0b1f7dc"
+ },
+ "chatRoomId": "5c73531c-6fc4-426c-adcb-afc5c140a0f7",
+ "user": "klaus",
+ "id": {
+ "$numberLong": "1"
+ },
+ "serial": {
+ "$numberLong": "3"
+ },
+ "time": "2023-01-13T20:43:16.804122604",
+ "text": "Ja? Nein? Vielleicht??",
+ "_class": "de.juplo.kafka.chat.backend.persistence.storage.mongodb.MessageTo"
+}
+{
+ "_id": {
+ "$oid": "64f7953ddf7a9063e0b1f7dd"
+ },
+ "chatRoomId": "5c73531c-6fc4-426c-adcb-afc5c140a0f7",
+ "user": "peter",
+ "id": {
+ "$numberLong": "2"
+ },
+ "serial": {
+ "$numberLong": "1"
+ },
+ "time": "2023-09-05T22:52:39.274621568",
+ "text": "Hallo, ich heiße Peter!",
+ "_class": "de.juplo.kafka.chat.backend.persistence.storage.mongodb.MessageTo"
+}
+{
+ "_id": {
+ "$oid": "64f7953ddf7a9063e0b1f7de"
+ },
+ "chatRoomId": "5c73531c-6fc4-426c-adcb-afc5c140a0f7",
+ "user": "peter",
+ "id": {
+ "$numberLong": "3"
+ },
+ "serial": {
+ "$numberLong": "2"
+ },
+ "time": "2023-09-05T22:52:41.226211877",
+ "text": "Hallo, ich heiße Peter!",
+ "_class": "de.juplo.kafka.chat.backend.persistence.storage.mongodb.MessageTo"
}