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

api-test

Package Overview
Dependencies
Maintainers
1
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

api-test - npm Package Compare versions

Comparing version 2.1.2 to 2.2.0

46

classes/Find.js

@@ -29,7 +29,41 @@ 'use strict'

var target = this.value.execute(options.context, '<find in ' + this.collection + '>'),
that = this,
collection = options.db.collection(this.collection)
if ('_id' in target) {
this._executeWithId(target, collection, options, done)
} else {
this._executeWithoutId(target, collection, options, done)
}
}
Find.prototype._executeWithId = function (target, collection, options, done) {
var that = this
collection.findOne({
_id: target._id
}, function (err, doc) {
if (err) {
return done(err)
}
try {
check(doc, target, options.strict, options.ignoredFindKeys)
} catch (e) {
console.log('\n-----\n' +
'\x1b[1;32mDocument with id ' + target._id + ' in ' + that.collection + ':\x1b[0m\n' +
stringify(doc, true, e.path) + '\n' +
'\x1b[1;32mTarget document:\x1b[0m\n' +
stringify(target, true, e.path) + '\n' +
'-----\n')
return done(new Error('Document mismatch in ' + that.collection))
}
done()
})
}
Find.prototype._executeWithoutId = function (target, collection, options, done) {
var that = this
collection.find().toArray(function (err, docs) {
var found, lastError
var errorPaths = [],
found

@@ -45,3 +79,3 @@ if (err) {

} catch (e) {
lastError = e.path
errorPaths.push(e.path)
return false

@@ -54,7 +88,7 @@ }

'\x1b[1;32mDocuments in ' + that.collection + ':\x1b[0m\n' +
docs.map(function (doc) {
return stringify(doc, true, lastError)
docs.map(function (doc, i) {
return stringify(doc, true, errorPaths[i])
}).join('\n---\n') + '\n' +
'\x1b[1;32mTarget document:\x1b[0m\n' +
stringify(target, true, lastError) + '\n' +
stringify(target, true) + '\n' +
'-----\n')

@@ -61,0 +95,0 @@ return done(new Error('No document found in ' + that.collection))

2

package.json
{
"name": "api-test",
"version": "2.1.2",
"version": "2.2.0",
"author": "Sitegui <sitegui@sitegui.com.br>",

@@ -5,0 +5,0 @@ "description": "API testing made simple",

@@ -8,2 +8,4 @@ # Database insertion

base // this should not alter base
### user2 in User
base

@@ -15,2 +17,6 @@ ## Test

error: null
a: 'Hello'
a: 'Hello'
### Find in User
user // Find by id
### Find in User
base // Find any that match everything
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