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

lowkie

Package Overview
Dependencies
Maintainers
2
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lowkie - npm Package Compare versions

Comparing version 1.0.2 to 1.1.0

12

lib/schema.js

@@ -57,3 +57,5 @@ 'use strict';

let validType = this.flattenedScheme[`${ key }.type`] || this.flattenedScheme[key];
if (typeof _document[key] === 'string' && (validType === String || validType === ObjectId)) {
if (validType === Date) {
result[key] === new Date();
} if (typeof _document[key] === 'string' && (validType === String || validType === ObjectId)) {
result[key] = _document[key].toString();

@@ -68,3 +70,9 @@ } else if (validType === Boolean) {

} else if (this.default_defs.indexOf(`${ key }.default`) !== -1 && !_document[key]) {
if (this.flattenedScheme[`${ key }.default`] === Date.now) result[key] = new Date();
if (typeof this.flattenedScheme[`${ key }.default`] === 'function') {
if (this.flattenedScheme[`${ key }.type`] === Date) {
result[key] = new Date();
} else {
result[key] = this.flattenedScheme[`${ key }.default`]();
}
}
else result[key] = this.flattenedScheme[`${ key }.default`];

@@ -71,0 +79,0 @@ } else if (typeof original_document[key] === 'object' && typeof this.flattenedScheme[key] === 'function' && this.flattenedScheme[key] === Object) { //schema type mixed

7

package.json
{
"name": "lowkie",
"version": "1.0.2",
"version": "1.1.0",
"license": "MIT",

@@ -44,4 +44,4 @@ "main": "index.js",

"lokijs": "^1.4.3",
"proxy-polyfill": "0.1.6",
"pluralize": "^4.0.0"
"pluralize": "^4.0.0",
"proxy-polyfill": "0.1.6"
},

@@ -78,2 +78,3 @@ "description": "My Custom lowkie / Express Applcation",

"mocha-lcov-reporter": "^1.2.0",
"moment": "^2.18.1",
"sinon": "^1.17.4",

@@ -80,0 +81,0 @@ "sinon-chai": "^2.8.0",

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

{"filename":"/Users/yawjosephetse/Developer/github/typesettin/lowkie/test/mock/sampledb.json","collections":[],"databaseVersion":1.1,"engineVersion":1.1,"autosave":false,"autosaveInterval":5000,"autosaveHandle":null,"throttledSaves":true,"options":{"serializationMethod":"normal","destructureDelimiter":"$<\n"},"persistenceMethod":"fs","persistenceAdapter":null,"verbose":false,"events":{"init":[null],"loaded":[],"flushChanges":[],"close":[],"changes":[],"warning":[]},"ENV":"NODEJS"}
{"filename":"/home/janbialostok/Developer/github/modules/lowkie/test/mock/sampledb.json","collections":[],"databaseVersion":1.1,"engineVersion":1.1,"autosave":false,"autosaveInterval":5000,"autosaveHandle":null,"throttledSaves":true,"options":{"serializationMethod":"normal","destructureDelimiter":"$<\n"},"persistenceMethod":"fs","persistenceAdapter":null,"verbose":false,"events":{"init":[null],"loaded":[],"flushChanges":[],"close":[],"changes":[],"warning":[]},"ENV":"NODEJS"}

@@ -12,2 +12,3 @@ 'use strict';

const removeTestDB = require('../util/removeTestDB');
const moment = require('moment');
const testUserSchemaScheme = {

@@ -26,2 +27,6 @@ name: String,

type: lowkieSchema.Types.ObjectId
},
createdat: {
type: Date,
default: Date.now
}

@@ -70,3 +75,3 @@ };

expect(testUserSchema.createDoc({})._id).to.be.an('string');
expect(Object.keys(testUserSchema.createDoc({})).length).to.eql(2);
expect(Object.keys(testUserSchema.createDoc({})).length).to.eql(3);
});

@@ -88,3 +93,3 @@ it('should allow for custom Ids', () => {

expect(newUser.invalidprop).to.not.exist;
expect(Object.keys(newUser).length).to.eql(6);
expect(Object.keys(newUser).length).to.eql(7);
expect(newUser._id).to.be.a('string');

@@ -110,7 +115,16 @@ });

active: true,
age: 18,
invalidprop: 'whatever',
age: 18
});
expect(newUser.profile).to.equal('no profile');
});
it('Should respect function definitions as default schema props', () => {
let newUser = testUserSchema.createDoc({
name: 'anothertestuser',
email: 'anotheruser@domain.tld',
active: true,
age: 21
});
let date = moment();
expect(moment(newUser.createdat).isSame(date, 'day')).to.be.true;
});
it('Should allow the definition of a populated field', (done) => {

@@ -117,0 +131,0 @@ return testAccountModel.insert({

Sorry, the diff of this file is not supported yet

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