Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

xpress-mongo

Package Overview
Dependencies
Maintainers
1
Versions
149
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

xpress-mongo - npm Package Compare versions

Comparing version 0.0.39 to 0.0.40

20

js/src/XMongoSchemaBuilder.js

@@ -11,3 +11,13 @@ "use strict";

const isArray = (v) => Array.isArray(v);
const isDate = (v) => v instanceof Date;
const isDate = (v) => {
if (v instanceof Date) {
return true;
}
else if (typeof v === "string") {
return !isNaN(new Date(v).getTime());
}
else {
return false;
}
};
const isNumber = (v) => !isBoolean(v) && !isNaN(v);

@@ -85,2 +95,10 @@ const is = {

.validator(isDate)
.cast((value) => {
if (value instanceof Date) {
return value;
}
else {
return new Date(value);
}
})
.validatorError((key) => `(${key}) is not a Date`);

@@ -87,0 +105,0 @@ },

4

package.json
{
"name": "xpress-mongo",
"version": "0.0.39",
"version": "0.0.40",
"description": "Light Weight ODM for mongoDb",

@@ -11,3 +11,3 @@ "main": "js/index.js",

"scripts": {
"test": "node tests/test.js"
"test": "nodemon tests/test.js"
},

@@ -14,0 +14,0 @@ "repository": {

@@ -11,3 +11,11 @@ import XMongoDataType = require("./XMongoDataType");

const isArray = (v: any) => Array.isArray(v);
const isDate = (v: any) => v instanceof Date;
const isDate = (v: any) => {
if (v instanceof Date) {
return true
} else if (typeof v === "string") {
return !isNaN(new Date(v).getTime())
} else {
return false
}
};
const isNumber = (v: any) => !isBoolean(v) && !isNaN(v);

@@ -49,3 +57,2 @@

.validatorError((key) => `(${key}) is not a Mongodb-ObjectID`);
},

@@ -107,2 +114,9 @@

.validator(isDate)
.cast((value) => {
if (value instanceof Date) {
return value
} else {
return new Date(value)
}
})
.validatorError((key) => `(${key}) is not a Date`);

@@ -109,0 +123,0 @@ },

@@ -1,2 +0,2 @@

const {Client} = require('../index');
const {Client} = require('../');

@@ -3,0 +3,0 @@ const db = "mongodb://127.0.0.1:27017";

@@ -1,2 +0,2 @@

const {is, ModelDataType} = require('../index');
const {is, ModelDataType} = require('../');
const Database = global['Database'];

@@ -39,3 +39,3 @@

]),
created_at: is.Date().required()
updated_at: is.Date().required()
};

@@ -42,0 +42,0 @@

@@ -12,15 +12,14 @@ const connection = require('./connection');

*/
const guest = new Users().set({
type: 'guest',
first_name: 'Hello',
last_name: 'World',
guestId: Users.id('5e5acba088ebeef8a715ca43'),
updated_at: 'Fri, 03 Apr 2020 00:00:00 GMT'
});
// console.log(guest.data);
console.log(guest.validate());
const guest = new Users().set({
type: 'guest',
first_name: 'Hello',
last_name: 'World',
guestId: Users.id('5e5acba088ebeef8a715ca43')
});
// console.log(guest.data);
console.log(guest.validate());
/**

@@ -27,0 +26,0 @@ * End Async Space

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc