shuttlepro-shared 1.2.2 → 1.2.4

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.
@@ -6,7 +6,7 @@ const CACHE_KEY_ALL = "workspaces_all";
6
6
  const getCachedWorkspaces = async () => {
7
7
  let workspaces = await getRedisData(CACHE_KEY_ALL);
8
8
  if (!workspaces) {
9
- workspaces = await Workspace.find().exec();
9
+ workspaces = await Workspace.find().lean().exec();
10
10
  await setRedisData(CACHE_KEY_ALL, workspaces);
11
11
  } else {
12
12
  workspaces = workspaces;
@@ -15,7 +15,7 @@ const getCachedWorkspaces = async () => {
15
15
  };
16
16
 
17
17
  const updateCachedWorkspaces = async () => {
18
- const workspaces = await Workspace.find().exec();
18
+ const workspaces = await Workspace.find().lean().exec();
19
19
  await setRedisData(CACHE_KEY_ALL, workspaces);
20
20
  };
21
21
 
@@ -29,7 +29,6 @@ const createWorkspace = async (data) => {
29
29
  const findWorkspaceById = async (id, select = []) => {
30
30
  const workspaces = await getCachedWorkspaces();
31
31
  const workspace = workspaces.find((ws) => ws._id.toString() === id) || null;
32
-
33
32
  if (workspace && select.length > 0) {
34
33
  return select.reduce((result, field) => {
35
34
  if (workspace[field] !== undefined) {
@@ -38,7 +37,6 @@ const findWorkspaceById = async (id, select = []) => {
38
37
  return result;
39
38
  }, {});
40
39
  }
41
-
42
40
  return workspace;
43
41
  };
44
42
 
@@ -70,6 +68,7 @@ const updateWorkspace = async (id, data) => {
70
68
  const updatedWorkspace = await Workspace.findByIdAndUpdate(id, data, {
71
69
  new: true,
72
70
  }).exec();
71
+
73
72
  if (updatedWorkspace) {
74
73
  await updateCachedWorkspaces();
75
74
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shuttlepro-shared",
3
- "version": "1.2.2",
3
+ "version": "1.2.4",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {