not-node 6.5.58 → 6.5.60

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "not-node",
3
- "version": "6.5.58",
3
+ "version": "6.5.60",
4
4
  "description": "node complimentary part for client side notFramework.",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/src/common.js CHANGED
@@ -342,14 +342,17 @@ module.exports.generatePaths = (content = [], relative = "src") => {
342
342
  **/
343
343
  module.exports.getIP = (req) => {
344
344
  if (req) {
345
- return (
345
+ const ip =
346
346
  (req.headers && req.headers["x-forwarded-for"]) ||
347
347
  (req.connection && req.connection.remoteAddress) ||
348
348
  (req.socket && req.socket.remoteAddress) ||
349
349
  (req.connection &&
350
350
  req.connection.socket &&
351
- req.connection.socket.remoteAddress)
352
- );
351
+ req.connection.socket.remoteAddress);
352
+ if (ip && ip.indexOf(",") > -1) {
353
+ return ip.split(",")[0];
354
+ }
355
+ return ip;
353
356
  } else {
354
357
  return undefined;
355
358
  }
@@ -100,9 +100,17 @@ class ModelRoutine {
100
100
  filter.__latest = true;
101
101
  filter.__closed = false;
102
102
  if (ModelConstructor.findOneAndUpdate) {
103
+ const setData = {}, unsetData = {};
104
+ Object.keys(data).forEach((key)=>{
105
+ if(typeof data[key] === 'undefined'){
106
+ unsetData[key] = 1;
107
+ }else{
108
+ setData[key] = data[key];
109
+ }
110
+ });
103
111
  const updateResult = await ModelConstructor.findOneAndUpdate(
104
112
  filter,
105
- { $set: data },
113
+ { $set: setData, $unset: unsetData },
106
114
  {
107
115
  returnDocument: "after"
108
116
  }