From ea48d3c7049cf2b2431edee41159cafb63ec7336 Mon Sep 17 00:00:00 2001
From: Jason King <837490+jsonking@users.noreply.github.com>
Date: Sat, 20 Feb 2021 16:58:40 +0000
Subject: [PATCH] #90 Use ListCollectionNamesStatment in
DropAllCollectionsStatement and tidy hrefs in javadoc
---
.../ext/mongodb/statement/CreateCollectionStatement.java | 2 +-
.../ext/mongodb/statement/DropAllCollectionsStatement.java | 4 +---
.../ext/mongodb/statement/DropCollectionStatement.java | 7 +------
.../ext/mongodb/statement/InsertManyStatement.java | 2 +-
.../ext/mongodb/statement/InsertOneStatement.java | 2 +-
5 files changed, 5 insertions(+), 12 deletions(-)
diff --git a/src/main/java/liquibase/ext/mongodb/statement/CreateCollectionStatement.java b/src/main/java/liquibase/ext/mongodb/statement/CreateCollectionStatement.java
index cadd5258..eef06a53 100644
--- a/src/main/java/liquibase/ext/mongodb/statement/CreateCollectionStatement.java
+++ b/src/main/java/liquibase/ext/mongodb/statement/CreateCollectionStatement.java
@@ -27,7 +27,7 @@
/**
* Creates a collection via the database runCommand method
* For a list of supported options see the reference page:
- * https://docs.mongodb.com/manual/reference/command/create/#create
+ * @see create
*/
@Getter
@EqualsAndHashCode(callSuper = true)
diff --git a/src/main/java/liquibase/ext/mongodb/statement/DropAllCollectionsStatement.java b/src/main/java/liquibase/ext/mongodb/statement/DropAllCollectionsStatement.java
index 9ffad94a..34517dc0 100644
--- a/src/main/java/liquibase/ext/mongodb/statement/DropAllCollectionsStatement.java
+++ b/src/main/java/liquibase/ext/mongodb/statement/DropAllCollectionsStatement.java
@@ -20,13 +20,11 @@
* #L%
*/
-import com.mongodb.client.MongoCollection;
import liquibase.ext.mongodb.database.MongoLiquibaseDatabase;
import liquibase.nosql.statement.NoSqlExecuteStatement;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
-import org.bson.Document;
import java.util.function.Consumer;
@@ -44,7 +42,7 @@ public String getCommandName() {
@Override
public void execute(final MongoLiquibaseDatabase database) {
- getMongoDatabase(database).listCollectionNames()
+ new ListCollectionNamesStatement().queryForList(database).stream()
.map(DropCollectionStatement::new)
.forEach((Consumer super DropCollectionStatement>) s -> s.execute(database));
}
diff --git a/src/main/java/liquibase/ext/mongodb/statement/DropCollectionStatement.java b/src/main/java/liquibase/ext/mongodb/statement/DropCollectionStatement.java
index babb0bd8..626aa991 100644
--- a/src/main/java/liquibase/ext/mongodb/statement/DropCollectionStatement.java
+++ b/src/main/java/liquibase/ext/mongodb/statement/DropCollectionStatement.java
@@ -28,7 +28,7 @@
/**
* Drops a collection
- * See https://docs.mongodb.com/manual/reference/command/drop/ for supported options
+ * See @see drop for supported options
*/
@Getter
@EqualsAndHashCode(callSuper = true)
@@ -58,9 +58,4 @@ public String getCollectionName() {
return command.getString(RUN_COMMAND_NAME);
}
- @Override
- public String toJs() {
- return String.format("db.%s.drop();", getCollectionName());
- }
-
}
diff --git a/src/main/java/liquibase/ext/mongodb/statement/InsertManyStatement.java b/src/main/java/liquibase/ext/mongodb/statement/InsertManyStatement.java
index b0b95d26..63a95338 100644
--- a/src/main/java/liquibase/ext/mongodb/statement/InsertManyStatement.java
+++ b/src/main/java/liquibase/ext/mongodb/statement/InsertManyStatement.java
@@ -34,7 +34,7 @@
/**
* Inserts many documents via the database runCommand method
* For a list of supported options see the reference page:
- * https://docs.mongodb.com/manual/reference/command/insert/
+ * @see insert
*/
@Getter
@EqualsAndHashCode(callSuper = true)
diff --git a/src/main/java/liquibase/ext/mongodb/statement/InsertOneStatement.java b/src/main/java/liquibase/ext/mongodb/statement/InsertOneStatement.java
index 9609d713..4b7dccf3 100644
--- a/src/main/java/liquibase/ext/mongodb/statement/InsertOneStatement.java
+++ b/src/main/java/liquibase/ext/mongodb/statement/InsertOneStatement.java
@@ -30,7 +30,7 @@
/**
* Inserts a document via the database runCommand method
* For a list of supported options see the reference page:
- * @see Insert
+ * @see insert
*/
@Getter
@EqualsAndHashCode(callSuper = true)