Mongodb: MongoDB is a free and open-source cross-platform document-oriented database program. Classified as a NoSQL database program, MongoDB uses JSON-like documents with schemas.
To run this project a MongoDB instance is required, so you can use either a local instalation or using Docker.
This part has 2 configuration files and 8 classes
-
src/main/resources/META-INF/beans.xml: CDI configuration file
-
src/main/resources/diana-mongodb.properties: Database connection configuration file
-
column/src/main/java/org/jnosql/demo/document/DocumentCollectionProducer.java: Connection handler
-
column/src/main/java/org/jnosql/demo/document/Person: This class is a
org.jnosql.artemis.Entity
to model a Person -
column/src/main/java/org/jnosql/demo/document/Address: This class is a
org.jnosql.artemis.Entity
to model an Address -
column/src/main/java/org/jnosql/demo/document/Job: This class is a
org.jnosql.artemis.Entity
to model a Job -
column/src/main/java/org/jnosql/demo/document/PersonBuilder: builder to create a Person entity
-
column/src/main/java/org/jnosql/demo/document/PersonRepository: Artemis Repository for Person entity
-
column/src/main/java/org/jnosql/demo/document/App: This class will be used to make the exercises.
- This class creates and persist into MongoDB one person with address and job and 2 telephone numbers and then queries it:
Person person = Person.builder(). withPhones(Arrays.asList("234", "432")) .withName("Name") .withAddress(address) .withJob(job) .withId(id).build();
-
column/src/main/java/org/jnosql/demo/document/App2: This class will be used to make the exercises.
- This class creates and persist into MongoDB one person with 2 telephone numbers and then queries it:
Person person = Person.builder(). withPhones(Arrays.asList("234", "432")) .withName("Name") .withId(id) .build();
-
Run the MongoDB Docker instance
docker run -d --name mongodb-instance -p 27017:27017 mongodb
-
Compile the project via Maven
mvn compile
-
Run the project via Maven
mvn exec:java -Dexec.mainClass="org.jnosql.demo.document.App" mvn exec:java -Dexec.mainClass="org.jnosql.demo.document.App2"
Now, It is time you explore the code: add new persons, more relationships, and create new queries. Also you can try to an create your own entities that can be used to respond some questions, next some ideas:
- Implement some searches against a MongoDB
- Search JUG members in a given city
- Search JUG members of legal drinking age
- Search JUGs in a region