Skip to content

Commit b8c5f98

Browse files
authored
Update ObjectMappingInsertOne.java
1 parent a830f7e commit b8c5f98

File tree

1 file changed

+18
-19
lines changed

1 file changed

+18
-19
lines changed

astra-db-client/src/test/java/com/dtsx/astra/sdk/documentation/ObjectMappingInsertOne.java

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,24 @@
66
import io.stargate.sdk.json.domain.odm.Document;
77

88
public class ObjectMappingInsertOne {
9-
static class Product {
10-
@JsonProperty("product_name") private String name;
11-
@JsonProperty("product_price") private Double price;
12-
Product(String name, Double price) {
13-
this.name = name;
14-
this.price = price;
15-
}
16-
}
9+
static class Product {
10+
@JsonProperty("product_name") private String name;
11+
@JsonProperty("product_price") private Double price;
12+
Product(String name, Double price) {
13+
this.name = name;
14+
this.price = price;
15+
}
16+
}
1717

18-
public static void main(String[] args) {
19-
AstraDB db = new AstraDB("<token>", "<api_endpoint>");
20-
AstraDBRepository<Product> productRepository = db
21-
.createCollection("collection_vector1", 14, Product.class);
22-
23-
// Upsert document
24-
productRepository.save(new Document<Product>()
25-
.id("product1")
26-
.vector(new float[]{1f, 0f, 1f, 1f, .5f, 1f, 0f, 0.3f, 0f, 0f, 0f, 0f, 0f, 0f})
27-
.data(new Product("product1", 9.99)));
28-
}
18+
public static void main(String[] args) {
19+
AstraDB db = new AstraDB("<token>", "<api_endpoint>");
20+
AstraDBRepository<Product> productRepository =
21+
db.createCollection("collection_vector1", 14, Product.class);
2922

23+
// Upsert document
24+
productRepository.save(new Document<Product>()
25+
.id("product1")
26+
.vector(new float[]{1f, 0f, 1f, 1f, .5f, 1f, 0f, 0.3f, 0f, 0f, 0f, 0f, 0f, 0f})
27+
.data(new Product("product1", 9.99)));
28+
}
3029
}

0 commit comments

Comments
 (0)