Socket
Socket
Sign inDemoInstall

q3-schema-utils

Package Overview
Dependencies
5
Maintainers
1
Versions
254
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.44 to 1.0.45

8

package.json
{
"name": "q3-schema-utils",
"version": "1.0.44",
"version": "1.0.45",
"main": "index.js",

@@ -10,6 +10,6 @@ "dependencies": {

"mongoose": "^5.7.1",
"q3-core-responder": "^1.0.72"
"q3-core-responder": "^1.0.73"
},
"devDependencies": {
"q3-test-utils": "^1.0.82"
"q3-test-utils": "^1.0.83"
},

@@ -24,3 +24,3 @@ "jest": {

},
"gitHead": "930e31dbd00af28a39f5d4da78d360f8156a2497"
"gitHead": "97864c1c705f1fe012cddedbb1fa114993de3d2b"
}

@@ -68,3 +68,3 @@ const mongoose = require('mongoose');

await Model.deleteMany({});
await mongoose.disconnect();
// await mongoose.disconnect();
});

@@ -83,11 +83,10 @@

describe('findStrictly', () => {
it('should throw', async () => {
it('should throw', () =>
expect(
Model.findStrictly(mongoose.Types.ObjectId()),
).rejects.toThrowError();
});
).rejects.toThrowError());
it('should return single result with virtuals', async () => {
const { _id: id } = await Model.create(stub);
expect(
return expect(
Model.findStrictly(id),

@@ -145,2 +144,17 @@ ).resolves.toHaveProperty('id');

});
it('should catch error before validating the parent', async () => {
const resp = await Model.create({ name: 'Test' });
return expect(
resp.pushSubDocument('dogs', {
breed: {
type: 'Corgi',
},
}),
).rejects.toMatchObject({
errors: expect.objectContaining({
breed: expect.any(Object),
}),
});
});
});

@@ -181,2 +195,17 @@

});
it('should catch validation errors early', async () => {
const resp = await Model.create(stub);
const {
dogs: [{ _id: id }],
} = resp;
const breed = { type: 'Boston' };
return expect(
resp.updateSubDocument('dogs', id, { breed }),
).rejects.toMatchObject({
errors: expect.objectContaining({
breed: expect.any(Object),
}),
});
});
});

@@ -194,11 +223,9 @@

describe('schema helpers', () => {
it('should return all ObjectIds', () => {
it('should return all ObjectIds', () =>
expect(Model.getReferentialPaths()).toEqual([
'friend',
]);
});
]));
it('should return all required fields', () => {
expect(Model.getRequiredFields()).toEqual(['age']);
});
it('should return all required fields', () =>
expect(Model.getRequiredFields()).toEqual(['age']));

@@ -205,0 +232,0 @@ it('should return all fields', () => {

@@ -75,2 +75,3 @@ /* eslint-disable func-names, no-param-reassign */

) {
let preValidationResult;
if (Array.isArray(this[field])) {

@@ -82,2 +83,12 @@ this[field].push(args);

try {
preValidationResult = this[field][
this[field].length - 1
].validateSync();
} catch (e) {
// noop
}
if (preValidationResult) throw preValidationResult;
return this.save({

@@ -116,2 +127,5 @@ redact: true,

subdoc.set(args);
const e = subdoc.validateSync();
if (e) throw e;
return this.save({

@@ -118,0 +132,0 @@ redact: true,

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc