win.doyto:doyto-query-mongodb
A Java OQM Framework for MongoDB
Science Score: 44.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
✓CITATION.cff file
Found CITATION.cff file -
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (7.6%) to scientific vocabulary
Keywords
Repository
A Java OQM Framework for MongoDB
Basic Info
- Host: GitHub
- Owner: doytowin
- License: apache-2.0
- Language: Java
- Default Branch: main
- Homepage: https://www.doyto.win
- Size: 2.55 MB
Statistics
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
- Releases: 2
Topics
Metadata Files
README.md
DoytoQueryMongoDB
Introduction
DoytoQueryMongoDB is an ORM framework for MongoDB in Java.
Quick tutorial with Spring Boot
This tutorial shows you how to create a CRUD web controller with Spring Boot and doyto-query-mongodb to access MongoDB.
The test data is from the MongoDB query-documents.
Refer to GitHub for complete code.
inventory.json
json
[
{"item": "journal", "qty": 25, "size": {"h": 14, "w": 21, "uom": "cm"}, "status": "A"},
{"item": "notebook", "qty": 50, "size": {"h": 8.5, "w": 11, "uom": "in"}, "status": "A"},
{"item": "paper", "qty": 100, "size": {"h": 8.5, "w": 11, "uom": "in"}, "status": "D"},
{"item": "planner", "qty": 75, "size": {"h": 22.85, "w": 30, "uom": "cm"}, "status": "D"},
{"item": "postcard", "qty": 45, "size": {"h": 10, "w": 15.25, "uom": "cm"}, "status": "A"}
]
0. Environment Preparation
Use start.spring.io to create a web project with spring boot 2 and following dependencies: - Lombok - Validation - Spring Web - Embedded MongoDB Database
1. Introduce Dependencies
xml
<dependencies>
<dependency>
<groupId>win.doyto</groupId>
<artifactId>doyto-query-mongodb</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>win.doyto</groupId>
<artifactId>doyto-query-web</artifactId>
<version>1.0.0</version>
</dependency>
...
</dependencies>
2. Business Classes
java
@Getter
@Setter
public class InventorySize {
private Double h;
private Double w;
private String uom;
}
java
@Getter
@Setter
@Entity(type = EntityType.MONGO_DB, database = "doyto", name = "c_inventory")
public class InventoryEntity extends MongoPersistable<String> {
private String item;
private Integer qty;
private InventorySize size;
private String status;
}
java
@Getter
@Setter
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class SizeQuery implements NestedQuery {
@JsonProperty("hLt")
private Double hLt;
private String uom;
}
java
@Getter
@Setter
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
public class InventoryQuery extends PageQuery {
private String itemContain;
private String status;
private SizeQuery size;
}
java
@RestController
@RequestMapping("inventory")
public class InventoryController extends AbstractEIQController<InventoryEntity, String, InventoryQuery> {
}
java
@SpringBootApplication
public class DemoApplication extends WebMvcConfigurerAdapter {
@Generated
public static void main(String[] args) {
SpringApplication.run(DoytoQueryDemoApplication.class, args);
}
}
3. Tests
```java @AutoConfigureMockMvc @SpringBootTest(properties = {"spring.mongodb.embedded.version=5.0.5"}) class InventoryMvcTest { @Resource protected MockMvc mockMvc;
@BeforeAll
static void beforeAll(@Autowired MockMvc mockMvc) throws Exception {
String data = "[" +
" {\"item\": \"journal\", \"qty\": 25, \"size\": {\"h\": 14, \"w\": 21, \"uom\": \"cm\"}, \"status\": \"A\"}," +
" {\"item\": \"notebook\", \"qty\": 50, \"size\": {\"h\": 8.5, \"w\": 11, \"uom\": \"in\"}, \"status\": \"A\"}," +
" {\"item\": \"paper\", \"qty\": 100, \"size\": {\"h\": 8.5, \"w\": 11, \"uom\": \"in\"}, \"status\": \"D\"}," +
" {\"item\": \"planner\", \"qty\": 75, \"size\": {\"h\": 22.85, \"w\": 30, \"uom\": \"cm\"}, \"status\": \"D\"}," +
" {\"item\": \"postcard\", \"qty\": 45, \"size\": {\"h\": 10, \"w\": 15.25, \"uom\": \"cm\"}, \"status\": \"A\"}" +
"]";
mockMvc.perform(post("/inventory/").content(data).contentType(MediaType.APPLICATION_JSON));
}
@Test
void queryExamples() throws Exception {
mockMvc.perform(get("/inventory/?itemContain=book"))
.andExpect(jsonPath("$.data.total").value(1));
mockMvc.perform(get("/inventory/?status=A"))
.andExpect(jsonPath("$.data.total").value(3));
mockMvc.perform(get("/inventory/?size.hLt=12&status=A"))
.andExpect(jsonPath("$.data.total").value(2))
.andExpect(jsonPath("$.data.list[*].item",
containsInRelativeOrder("notebook", "postcard")));
mockMvc.perform(get("/inventory/?size.uom=in"))
.andExpect(jsonPath("$.data.total").value(2))
.andExpect(jsonPath("$.data.list[*].item",
containsInRelativeOrder("notebook", "paper")));
}
} ```
Versions
| Module | Snapshot | Release |
|-------------------------------|----------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------|
| doyto-query-mongodb | |
|
| doyto-query-mongodb-spring-tx |
|
|
License
This project is under the Apache Licence v2.
Owner
- Name: doytowin
- Login: doytowin
- Kind: organization
- Location: China
- Repositories: 11
- Profile: https://github.com/doytowin
Citation (CITATION.cff)
# This CITATION.cff file was generated with cffinit.
# Visit https://bit.ly/cffinit to generate yours today!
cff-version: 1.2.0
title: DoytoQueryMongoDB
message: >-
If you use this software, please cite it using the
metadata from this file.
type: software
authors:
- given-names: Zhen
family-names: Yuan
email: yuanzhen@doyto.win
orcid: 'https://orcid.org/0000-0002-2577-7102'
affiliation: 'DOYToWin, Inc.'
identifiers:
- type: url
value: >-
https://github.com/doytowin/doyto-query-mongodb/releases/tag/v1.0.0
repository-code: 'https://github.com/doytowin/doyto-query-mongodb'
url: 'https://www.doyto.win/'
repository-artifact: >-
https://central.sonatype.com/artifact/win.doyto/doyto-query-mongodb/
abstract: A Java OSM framework for MongoDB.
keywords:
- DoytoQuery
- MongoDB
- Java
license: Apache-2.0
commit: 0ec8f130ca75551e4020ff2869322dffd0ba88a5
version: 1.0.0
date-released: '2022-11-28'
GitHub Events
Total
Last Year
Packages
- Total packages: 2
- Total downloads: unknown
-
Total dependent packages: 1
(may contain duplicates) -
Total dependent repositories: 3
(may contain duplicates) - Total versions: 8
repo1.maven.org: win.doyto:doyto-query-mongodb
DoytoQuery MongoDB implementation
- Homepage: https://query.doyto.win/doyto-query-mongodb/
- Documentation: https://appdoc.app/artifact/win.doyto/doyto-query-mongodb/
- License: The Apache Software License, Version 2.0
-
Latest release: 2.0.0
published over 1 year ago
Rankings
repo1.maven.org: win.doyto:doyto-query-mongodb-spring-tx
Spring Transaction implementation for MongoDB
- Homepage: https://query.doyto.win/doyto-query-mongodb-spring-tx/
- Documentation: https://appdoc.app/artifact/win.doyto/doyto-query-mongodb-spring-tx/
- License: The Apache Software License, Version 2.0
-
Latest release: 2.0.0
published over 1 year ago