-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: documentation for jdbc and the dependencies for it (schema anal…
…ysis and sql execution)
- Loading branch information
1 parent
022cc63
commit 6b9dca2
Showing
15 changed files
with
205 additions
and
194 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Analyse Schema | ||
The driver supports an automated detection of the schema of an existing collection. The schema is used to detect the types of the columns. | ||
|
||
## Usage | ||
|
||
### Schema Analysis | ||
Analyse a collection to detect the values for each field and the percentage distribution of the types. | ||
|
||
<<< @/../src/test/scala/dev/mongocamp/driver/mongodb/schema/SchemaSpec.scala#schema-analysis | ||
|
||
### Detect Schema | ||
The Schema Detector can be used to detect the schema of a collection and is based on [Schema Anaysis](analyse-schema.md#schema-analysis). The schema is used to detect the types of the columns and generate a [JSON Schema](https://json-schema.org) for the collection. In case of multiple types of a field the Generation of the JSON Schema use the type with the most elements. | ||
|
||
:::tip | ||
The [JSON Schema](https://json-schema.org) format can be use to validate or generate data, as well to secure your [Mongo Collection](https://www.mongodb.com/docs/manual/core/schema-validation/). | ||
::: | ||
|
||
<<< @/../src/test/scala/dev/mongocamp/driver/mongodb/schema/SchemaSpec.scala#schema-explorer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# SQL Support | ||
|
||
Since Version 2.7.1 the driver supports [SQL queries](queryholder.md) on MongoDB. The SQL queries are converted to MongoDB queries and could executed on the MongoDB database. | ||
|
||
The driver also supports a [JDBC driver](jdbc-driver.md) to use the SQL queries in your application and migrate your database with liquibase for example. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# JDBC driver | ||
|
||
The JDBC driver is a way to use the SQL queries in your application and run them like a 'normal' SQL database. The driver is based on the [MongoSqlQueryHolder](queryholder.md) to convert the SQL query to a Mongo query and execute it on the MongoDB database. | ||
|
||
## Usage | ||
|
||
### Register Driver | ||
In some environments you have to register the driver manually. This is the case for example in the tests. | ||
|
||
<<< @/../src/test/scala/dev/mongocamp/driver/mongodb/jdbc/BaseJdbcSpec.scala#register-driver | ||
|
||
After the driver is registered you can use the driver like a normal [JDBC driver](https://www.baeldung.com/java-jdbc). | ||
|
||
:::tip | ||
The most default sql statements are supported, but because the difference between MongoDb and SQL the driver can't support SQL statements with subselects. | ||
::: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# SQL Converter to Mongo Query | ||
|
||
The MongoSqlQueryHolder provides a way to convert a SQL query to a Mongo query and execute it on a Mongo database. | ||
|
||
## Usage | ||
|
||
Initialize the query holder with the SQL query you want to analyse or execute. | ||
|
||
<<< @/../src/test/scala/dev/mongocamp/driver/mongodb/sql/SelectSqlSpec.scala#initialize-query-holder | ||
|
||
In most cases you simply want to run the query and get the result as a `Seq[Document]`. | ||
::: tip | ||
The method run returns a classical MongoDb Observable use the implicits to convert it to a `Seq[Document]`. | ||
::: | ||
<<< @/../src/test/scala/dev/mongocamp/driver/mongodb/sql/SelectSqlSpec.scala#query-holder-run | ||
|
||
You can also get the information about the collection and the keys that are used in the query. | ||
|
||
<<< @/../src/test/scala/dev/mongocamp/driver/mongodb/sql/SelectSqlSpec.scala#extract-collection | ||
<<< @/../src/test/scala/dev/mongocamp/driver/mongodb/sql/SelectSqlSpec.scala#select-keys | ||
|
||
In some cases you need the information about the function calls in the query, for example in your own [jdbc driver](jdbc-driver.md) implementation. Because the difference of MongoDb and SQL for example a sql `select count(*) from empty-collection` is a list documents with one element and the MongoDb has no document in it. | ||
|
||
<<< @/../src/test/scala/dev/mongocamp/driver/mongodb/sql/SelectSqlSpec.scala#has-function-call |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,28 @@ | ||
{ | ||
"name" : "mongodb-driver", | ||
"organization" : "dev.mongocamp", | ||
"version" : "2.7.1.snapshot", | ||
"author" : "info@mongocamp.dev", | ||
"license" : "Apache-2.0", | ||
"type" : "module", | ||
"repository" : { | ||
"type" : "git", | ||
"url" : "git+https://github.com/MongoCamp/mongodb-driver.git" | ||
"name": "mongodb-driver", | ||
"organization": "dev.mongocamp", | ||
"version": "2.8.0", | ||
"author": "info@mongocamp.dev", | ||
"license": "Apache-2.0", | ||
"type": "module", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/MongoCamp/mongodb-driver.git" | ||
}, | ||
"bugs" : { | ||
"url" : "https://github.com/MongoCamp/mongodb-driver/issues" | ||
"bugs": { | ||
"url": "https://github.com/MongoCamp/mongodb-driver/issues" | ||
}, | ||
"homepage" : "https://mongodb-driver.mongocamp.dev/", | ||
"scripts" : { | ||
"docs:serve" : "vitepress serve docs --port 5555", | ||
"docs:build" : "pnpm docs:external; vitepress build docs", | ||
"docs:external" : "sh docs/external/fileloader.sh", | ||
"docs:dev" : "pnpm docs:external; vitepress dev docs" | ||
"homepage": "https://mongodb-driver.mongocamp.dev/", | ||
"scripts": { | ||
"docs:serve": "vitepress serve docs --port 5555", | ||
"docs:build": "pnpm docs:external; vitepress build docs", | ||
"docs:external": "sh docs/external/fileloader.sh", | ||
"docs:dev": "pnpm docs:external; vitepress dev docs" | ||
}, | ||
"devDependencies" : { | ||
"@iconify-json/fluent-emoji" : "^1.1.18", | ||
"@unocss/preset-icons" : "^0.58.5", | ||
"unocss" : "^0.58.5", | ||
"vitepress" : "1.0.0-rc.45" | ||
"devDependencies": { | ||
"@iconify-json/fluent-emoji": "^1.2.1", | ||
"@unocss/preset-icons": "^0.63.4", | ||
"unocss": "^0.63.4", | ||
"vitepress": "1.4.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.