diff --git a/src/main/java/com/kingsrook/qqq/backend/core/actions/CountAction.java b/src/main/java/com/kingsrook/qqq/backend/core/actions/CountAction.java
new file mode 100644
index 00000000..ed2531d4
--- /dev/null
+++ b/src/main/java/com/kingsrook/qqq/backend/core/actions/CountAction.java
@@ -0,0 +1,52 @@
+/*
+ * QQQ - Low-code Application Framework for Engineers.
+ * Copyright (C) 2021-2022. Kingsrook, LLC
+ * 651 N Broad St Ste 205 # 6917 | Middletown DE 19709 | United States
+ * contact@kingsrook.com
+ * https://github.com/Kingsrook/
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+package com.kingsrook.qqq.backend.core.actions;
+
+
+import com.kingsrook.qqq.backend.core.exceptions.QException;
+import com.kingsrook.qqq.backend.core.model.actions.count.CountRequest;
+import com.kingsrook.qqq.backend.core.model.actions.count.CountResult;
+import com.kingsrook.qqq.backend.core.modules.QBackendModuleDispatcher;
+import com.kingsrook.qqq.backend.core.modules.interfaces.QBackendModuleInterface;
+
+
+/*******************************************************************************
+ ** Action to run a count against a table.
+ **
+ *******************************************************************************/
+public class CountAction
+{
+ /*******************************************************************************
+ **
+ *******************************************************************************/
+ public CountResult execute(CountRequest countRequest) throws QException
+ {
+ ActionHelper.validateSession(countRequest);
+
+ QBackendModuleDispatcher qBackendModuleDispatcher = new QBackendModuleDispatcher();
+ QBackendModuleInterface qModule = qBackendModuleDispatcher.getQBackendModule(countRequest.getBackend());
+ // todo pre-customization - just get to modify the request?
+ CountResult countResult = qModule.getCountInterface().execute(countRequest);
+ // todo post-customization - can do whatever w/ the result if you want
+ return countResult;
+ }
+}
diff --git a/src/main/java/com/kingsrook/qqq/backend/core/model/actions/count/CountRequest.java b/src/main/java/com/kingsrook/qqq/backend/core/model/actions/count/CountRequest.java
new file mode 100644
index 00000000..1c18f0b9
--- /dev/null
+++ b/src/main/java/com/kingsrook/qqq/backend/core/model/actions/count/CountRequest.java
@@ -0,0 +1,81 @@
+/*
+ * QQQ - Low-code Application Framework for Engineers.
+ * Copyright (C) 2021-2022. Kingsrook, LLC
+ * 651 N Broad St Ste 205 # 6917 | Middletown DE 19709 | United States
+ * contact@kingsrook.com
+ * https://github.com/Kingsrook/
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+package com.kingsrook.qqq.backend.core.model.actions.count;
+
+
+import com.kingsrook.qqq.backend.core.model.actions.AbstractQTableRequest;
+import com.kingsrook.qqq.backend.core.model.actions.query.QQueryFilter;
+import com.kingsrook.qqq.backend.core.model.metadata.QInstance;
+
+
+/*******************************************************************************
+ ** Request data for the Count action
+ **
+ *******************************************************************************/
+public class CountRequest extends AbstractQTableRequest
+{
+ private QQueryFilter filter;
+
+
+
+ /*******************************************************************************
+ **
+ *******************************************************************************/
+ public CountRequest()
+ {
+ }
+
+
+
+ /*******************************************************************************
+ **
+ *******************************************************************************/
+ public CountRequest(QInstance instance)
+ {
+ super(instance);
+ }
+
+
+
+ /*******************************************************************************
+ ** Getter for filter
+ **
+ *******************************************************************************/
+ public QQueryFilter getFilter()
+ {
+ return filter;
+ }
+
+
+
+ /*******************************************************************************
+ ** Setter for filter
+ **
+ *******************************************************************************/
+ public void setFilter(QQueryFilter filter)
+ {
+ this.filter = filter;
+ }
+
+
+
+}
diff --git a/src/main/java/com/kingsrook/qqq/backend/core/model/actions/count/CountResult.java b/src/main/java/com/kingsrook/qqq/backend/core/model/actions/count/CountResult.java
new file mode 100644
index 00000000..bc932bba
--- /dev/null
+++ b/src/main/java/com/kingsrook/qqq/backend/core/model/actions/count/CountResult.java
@@ -0,0 +1,55 @@
+/*
+ * QQQ - Low-code Application Framework for Engineers.
+ * Copyright (C) 2021-2022. Kingsrook, LLC
+ * 651 N Broad St Ste 205 # 6917 | Middletown DE 19709 | United States
+ * contact@kingsrook.com
+ * https://github.com/Kingsrook/
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+package com.kingsrook.qqq.backend.core.model.actions.count;
+
+
+import com.kingsrook.qqq.backend.core.model.actions.AbstractQResult;
+
+
+/*******************************************************************************
+ ** Result for a query action
+ **
+ *******************************************************************************/
+public class CountResult extends AbstractQResult
+{
+ private Integer count;
+
+
+
+ /*******************************************************************************
+ **
+ *******************************************************************************/
+ public Integer getCount()
+ {
+ return count;
+ }
+
+
+
+ /*******************************************************************************
+ **
+ *******************************************************************************/
+ public void setCount(Integer count)
+ {
+ this.count = count;
+ }
+}
diff --git a/src/main/java/com/kingsrook/qqq/backend/core/modules/interfaces/CountInterface.java b/src/main/java/com/kingsrook/qqq/backend/core/modules/interfaces/CountInterface.java
new file mode 100644
index 00000000..9d13d942
--- /dev/null
+++ b/src/main/java/com/kingsrook/qqq/backend/core/modules/interfaces/CountInterface.java
@@ -0,0 +1,40 @@
+/*
+ * QQQ - Low-code Application Framework for Engineers.
+ * Copyright (C) 2021-2022. Kingsrook, LLC
+ * 651 N Broad St Ste 205 # 6917 | Middletown DE 19709 | United States
+ * contact@kingsrook.com
+ * https://github.com/Kingsrook/
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+package com.kingsrook.qqq.backend.core.modules.interfaces;
+
+
+import com.kingsrook.qqq.backend.core.exceptions.QException;
+import com.kingsrook.qqq.backend.core.model.actions.count.CountRequest;
+import com.kingsrook.qqq.backend.core.model.actions.count.CountResult;
+
+
+/*******************************************************************************
+ ** Interface for the Count action.
+ **
+ *******************************************************************************/
+public interface CountInterface
+{
+ /*******************************************************************************
+ **
+ *******************************************************************************/
+ CountResult execute(CountRequest queryRequest) throws QException;
+}
diff --git a/src/main/java/com/kingsrook/qqq/backend/core/modules/interfaces/QBackendModuleInterface.java b/src/main/java/com/kingsrook/qqq/backend/core/modules/interfaces/QBackendModuleInterface.java
index 6ebfddfc..c884b383 100644
--- a/src/main/java/com/kingsrook/qqq/backend/core/modules/interfaces/QBackendModuleInterface.java
+++ b/src/main/java/com/kingsrook/qqq/backend/core/modules/interfaces/QBackendModuleInterface.java
@@ -53,6 +53,15 @@ public interface QBackendModuleInterface
return QTableBackendDetails.class;
}
+ /*******************************************************************************
+ **
+ *******************************************************************************/
+ default CountInterface getCountInterface()
+ {
+ throwNotImplemented("Count");
+ return null;
+ }
+
/*******************************************************************************
**
*******************************************************************************/
diff --git a/src/main/java/com/kingsrook/qqq/backend/core/modules/mock/MockBackendModule.java b/src/main/java/com/kingsrook/qqq/backend/core/modules/mock/MockBackendModule.java
index 652d7be6..706ccf8b 100644
--- a/src/main/java/com/kingsrook/qqq/backend/core/modules/mock/MockBackendModule.java
+++ b/src/main/java/com/kingsrook/qqq/backend/core/modules/mock/MockBackendModule.java
@@ -23,6 +23,7 @@ package com.kingsrook.qqq.backend.core.modules.mock;
import com.kingsrook.qqq.backend.core.model.metadata.QBackendMetaData;
+import com.kingsrook.qqq.backend.core.modules.interfaces.CountInterface;
import com.kingsrook.qqq.backend.core.modules.interfaces.DeleteInterface;
import com.kingsrook.qqq.backend.core.modules.interfaces.InsertInterface;
import com.kingsrook.qqq.backend.core.modules.interfaces.QBackendModuleInterface;
@@ -61,6 +62,17 @@ public class MockBackendModule implements QBackendModuleInterface
+ /*******************************************************************************
+ **
+ *******************************************************************************/
+ @Override
+ public CountInterface getCountInterface()
+ {
+ return new MockCountAction();
+ }
+
+
+
/*******************************************************************************
**
*******************************************************************************/
diff --git a/src/main/java/com/kingsrook/qqq/backend/core/modules/mock/MockCountAction.java b/src/main/java/com/kingsrook/qqq/backend/core/modules/mock/MockCountAction.java
new file mode 100644
index 00000000..8d3aa80f
--- /dev/null
+++ b/src/main/java/com/kingsrook/qqq/backend/core/modules/mock/MockCountAction.java
@@ -0,0 +1,56 @@
+/*
+ * QQQ - Low-code Application Framework for Engineers.
+ * Copyright (C) 2021-2022. Kingsrook, LLC
+ * 651 N Broad St Ste 205 # 6917 | Middletown DE 19709 | United States
+ * contact@kingsrook.com
+ * https://github.com/Kingsrook/
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+package com.kingsrook.qqq.backend.core.modules.mock;
+
+
+import com.kingsrook.qqq.backend.core.exceptions.QException;
+import com.kingsrook.qqq.backend.core.model.actions.count.CountRequest;
+import com.kingsrook.qqq.backend.core.model.actions.count.CountResult;
+import com.kingsrook.qqq.backend.core.modules.interfaces.CountInterface;
+
+
+/*******************************************************************************
+ ** Mocked up version of query action.
+ **
+ *******************************************************************************/
+public class MockCountAction implements CountInterface
+{
+
+ /*******************************************************************************
+ **
+ *******************************************************************************/
+ @SuppressWarnings("checkstyle:MagicNumber")
+ public CountResult execute(CountRequest countRequest) throws QException
+ {
+ try
+ {
+ CountResult rs = new CountResult();
+ rs.setCount(1976);
+
+ return rs;
+ }
+ catch(Exception e)
+ {
+ throw new QException("Error executing count", e);
+ }
+ }
+}
diff --git a/src/test/java/com/kingsrook/qqq/backend/core/actions/CountActionTest.java b/src/test/java/com/kingsrook/qqq/backend/core/actions/CountActionTest.java
new file mode 100644
index 00000000..d6be8c98
--- /dev/null
+++ b/src/test/java/com/kingsrook/qqq/backend/core/actions/CountActionTest.java
@@ -0,0 +1,54 @@
+/*
+ * QQQ - Low-code Application Framework for Engineers.
+ * Copyright (C) 2021-2022. Kingsrook, LLC
+ * 651 N Broad St Ste 205 # 6917 | Middletown DE 19709 | United States
+ * contact@kingsrook.com
+ * https://github.com/Kingsrook/
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+package com.kingsrook.qqq.backend.core.actions;
+
+
+import com.kingsrook.qqq.backend.core.exceptions.QException;
+import com.kingsrook.qqq.backend.core.model.actions.count.CountRequest;
+import com.kingsrook.qqq.backend.core.model.actions.count.CountResult;
+import com.kingsrook.qqq.backend.core.utils.TestUtils;
+import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+
+/*******************************************************************************
+ ** Unit test for CountAction
+ **
+ *******************************************************************************/
+class CountActionTest
+{
+
+ /*******************************************************************************
+ ** At the core level, there isn't much that can be asserted, as it uses the
+ ** mock implementation - just confirming that all of the "wiring" works.
+ **
+ *******************************************************************************/
+ @Test
+ public void test() throws QException
+ {
+ CountRequest request = new CountRequest(TestUtils.defineInstance());
+ request.setSession(TestUtils.getMockSession());
+ request.setTableName("person");
+ CountResult result = new CountAction().execute(request);
+ assertNotNull(result);
+ }
+}