powr-sdk-api 2.4.0 → 2.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/routes/forms.js
CHANGED
|
@@ -143,7 +143,8 @@ router.get('/getCount/:formName', async (req, res) => {
|
|
|
143
143
|
const {
|
|
144
144
|
projectId
|
|
145
145
|
} = req.query;
|
|
146
|
-
const
|
|
146
|
+
const db = await getDb();
|
|
147
|
+
const studentsFormCollection = db.collection('studentsForm');
|
|
147
148
|
|
|
148
149
|
// Build query object
|
|
149
150
|
let query = {
|
|
@@ -205,7 +206,8 @@ router.post('/create-form', upload.single('jsonFile'), async (req, res) => {
|
|
|
205
206
|
message: 'formName is required in JSON data'
|
|
206
207
|
});
|
|
207
208
|
}
|
|
208
|
-
const
|
|
209
|
+
const db = await getDb();
|
|
210
|
+
const powrFormCollection = db.collection('powrForm');
|
|
209
211
|
const existingForm = await powrFormCollection.findOne({
|
|
210
212
|
formName: formData.formName,
|
|
211
213
|
projectId: projectId
|
package/dist/routes/profiles.js
CHANGED
|
@@ -9,10 +9,10 @@ const {
|
|
|
9
9
|
// Get all users for a project
|
|
10
10
|
router.get("/", async (req, res) => {
|
|
11
11
|
try {
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const profiles = await
|
|
12
|
+
const projectId = req.projectId; // Use middleware-injected projectId
|
|
13
|
+
|
|
14
|
+
const db = await getDb();
|
|
15
|
+
const profiles = await db.collection("profiles").find({
|
|
16
16
|
projectId: projectId
|
|
17
17
|
}).toArray();
|
|
18
18
|
if (profiles.length === 0) {
|
|
@@ -24,7 +24,7 @@ router.get("/", async (req, res) => {
|
|
|
24
24
|
|
|
25
25
|
// Get core user data for all profiles
|
|
26
26
|
const userIds = profiles.map(profile => profile.userId);
|
|
27
|
-
const users = await
|
|
27
|
+
const users = await db.collection("users").find({
|
|
28
28
|
_id: {
|
|
29
29
|
$in: userIds
|
|
30
30
|
}
|
package/dist/services/mongo.js
CHANGED
|
@@ -6,15 +6,12 @@
|
|
|
6
6
|
const {
|
|
7
7
|
MongoClient
|
|
8
8
|
} = require('mongodb');
|
|
9
|
-
const
|
|
10
|
-
getConfig
|
|
11
|
-
} = require('../config');
|
|
9
|
+
const config = require('../config');
|
|
12
10
|
let client = null;
|
|
13
11
|
let db = null;
|
|
14
12
|
const connectDB = async () => {
|
|
15
|
-
const config = getConfig();
|
|
16
13
|
if (!config.mongoUri) {
|
|
17
|
-
throw new Error('
|
|
14
|
+
throw new Error('POWR_DB_URI environment variable is required');
|
|
18
15
|
}
|
|
19
16
|
try {
|
|
20
17
|
client = new MongoClient(config.mongoUri);
|