hola-server 0.5.1 → 0.5.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/db/entity.js +1 -1
- package/package.json +1 -1
- package/router/read.js +13 -4
package/db/entity.js
CHANGED
|
@@ -128,7 +128,7 @@ class Entity {
|
|
|
128
128
|
const refer_entity = new Entity(get_entity_meta(search_field.ref));
|
|
129
129
|
const oids = await refer_entity.find_by_ref_value(value, { _id: 1 }, this.meta.collection);
|
|
130
130
|
if (oids.length > 0) {
|
|
131
|
-
and_array.push({ [search_field.name]: { "$
|
|
131
|
+
and_array.push({ [search_field.name]: { "$in": oids.map(o => o._id + "") } });
|
|
132
132
|
}
|
|
133
133
|
} else {
|
|
134
134
|
and_array.push(parse_search_value(search_field.name, search_field.type, value));
|
package/package.json
CHANGED
package/router/read.js
CHANGED
|
@@ -44,13 +44,22 @@ const init_read_router = function (router, meta) {
|
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
const param_obj = req.body;
|
|
47
|
+
|
|
47
48
|
if (meta.user_field) {
|
|
48
49
|
const [user_field] = meta.fields.filter(f => f.name == meta.user_field);
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
if (user_field && user_field.group == true) {
|
|
51
|
+
const user_ids = get_session_user_groups(req);
|
|
52
|
+
if (user_ids == null) {
|
|
53
|
+
throw new Error("no user group is found in session");
|
|
54
|
+
}
|
|
55
|
+
param_obj[meta.user_field] = user_ids;
|
|
56
|
+
} else {
|
|
57
|
+
const user_id = get_session_userid(req);
|
|
58
|
+
if (user_id == null) {
|
|
59
|
+
throw new Error("no user id is found in session");
|
|
60
|
+
}
|
|
61
|
+
param_obj[meta.user_field] = user_id;
|
|
52
62
|
}
|
|
53
|
-
param_obj[meta.user_field] = { "$in": user_ids };
|
|
54
63
|
}
|
|
55
64
|
|
|
56
65
|
const { code, err, total, data } = await entity.list_entity(query_params["_query"], null, param_obj);
|