# apijson-mongodb **Repository Path**: APIJSON/apijson-mongodb ## Basic Information - **Project Name**: apijson-mongodb - **Description**: 腾讯 APIJSON 的 MongoDB 数据库插件 - **Primary Language**: Java - **License**: Apache-2.0 - **Default Branch**: main - **Homepage**: https://github.com/APIJSON/apijson-mongodb - **GVP Project**: No ## Statistics - **Stars**: 2 - **Forks**: 0 - **Created**: 2024-01-05 - **Last Updated**: 2025-04-13 ## Categories & Tags **Categories**: Uncategorized **Tags**: APIJSON, MongoDB, Nosql, ORM, Java ## README # apijson-mongodb [![](https://jitpack.io/v/APIJSON/apijson-mongodb.svg)](https://jitpack.io/#APIJSON/apijson-mongodb) 腾讯 [APIJSON](https://github.com/Tencent/APIJSON) 的 MongoDB 数据库插件,可通过 Maven, Gradle 等远程依赖。
A MongoDB plugin for Tencent [APIJSON](https://github.com/Tencent/APIJSON) ![image](https://github-production-user-asset-6210df.s3.amazonaws.com/5738175/293696252-36406e20-b157-4121-bca7-280491462481.png) ## 添加依赖 ## Add Dependency ### Maven #### 1. 在 pom.xml 中添加 JitPack 仓库 #### 1. Add the JitPack repository to pom.xml ```xml jitpack.io https://jitpack.io ``` ![image](https://user-images.githubusercontent.com/5738175/167261814-d75d8fff-0e64-4534-a840-60ef628a8873.png)
#### 2. 在 pom.xml 中添加 apijson-mongodb 依赖 #### 2. Add the apijson-mongodb dependency to pom.xml ```xml com.github.APIJSON apijson-mongodb LATEST ```
https://github.com/APIJSON/APIJSON-Demo/blob/master/APIJSON-Java-Server/APIJSONBoot-MultiDataSource/pom.xml

### Gradle #### 1. 在项目根目录 build.gradle 中最后添加 JitPack 仓库 #### 1. Add the JitPack repository in your root build.gradle at the end of repositories ```gradle allprojects { repositories { maven { url 'https://jitpack.io' } } } ```
#### 2. 在项目某个 module 目录(例如 `app`) build.gradle 中添加 apijson-mongodb 依赖 #### 2. Add the apijson-mongodb dependency in one of your modules(such as `app`) ```gradle dependencies { implementation 'com.github.APIJSON:apijson-mongodb:latest' } ```


## 使用 ## Usage 在你项目继承 AbstractSQLExecutor 的子类重写方法 getValue
Override getValue in your SQLExecutor extends AbstractSQLExecutor ```java @Override protected Object getValue(SQLConfig config, ResultSet rs, ResultSetMetaData rsmd, int tablePosition, JSONObject table, int columnIndex, String lable, Map childMap) throws Exception { Object v = super.getValue(config, rs, rsmd, tablePosition, table, columnIndex, lable, childMap); return MongoUtil.getValue(v); } ``` #### 见 [MongoUtil](/src/main/java/apijson/mongodb/MongoUtil.java) 的注释及 [APIJSONBoot-MultiDataSource](https://github.com/APIJSON/APIJSON-Demo/blob/master/APIJSON-Java-Server/APIJSONBoot-MultiDataSource) 的 [DemoSQLExecutor](https://github.com/APIJSON/APIJSON-Demo/blob/master/APIJSON-Java-Server/APIJSONBoot-MultiDataSource/src/main/java/apijson/demo/DemoSQLExecutor.java)
#### See document in [MongoUtil](/src/main/java/apijson/mongodb/MongoUtil.java) and [DemoSQLExecutor](https://github.com/APIJSON/APIJSON-Demo/blob/master/APIJSON-Java-Server/APIJSONBoot-MultiDataSource/src/main/java/apijson/demo/DemoSQLExecutor.java) in [APIJSONBoot-MultiDataSource](https://github.com/APIJSON/APIJSON-Demo/blob/master/APIJSON-Java-Server/APIJSONBoot-MultiDataSource)


有问题可以去 Tencent/APIJSON 提 issue
https://github.com/Tencent/APIJSON/issues/36

#### 点右上角 ⭐Star 支持一下,谢谢 ^_^ #### Please ⭐Star this project ^_^ https://github.com/APIJSON/apijson-mongodb