loopback-connector-firestore
Advanced tools
Comparing version 1.0.6 to 1.0.7
@@ -25,2 +25,3 @@ const admin = require('firebase-admin'); | ||
this.db = admin.firestore(); | ||
this.db.settings({timestampsInSnapshots: true}); | ||
} | ||
@@ -42,6 +43,10 @@ | ||
if (snapshot.exists) { | ||
response.push(snapshot.data()); | ||
let completeItem = snapshot.data(); | ||
completeItem.id = snapshot.id; | ||
response.push(completeItem); | ||
} else { | ||
snapshot.forEach(item => { | ||
response.push(item.data()); | ||
let completeItem = item.data(); | ||
completeItem.id = item.id; | ||
response.push(completeItem); | ||
}); | ||
@@ -48,0 +53,0 @@ } |
{ | ||
"name": "loopback-connector-firestore", | ||
"version": "1.0.6", | ||
"version": "1.0.7", | ||
"description": "Firebase Firestore connector for the LoopBack framework.", | ||
@@ -9,3 +9,3 @@ "main": "index.js", | ||
"lint": "eslint --fix .", | ||
"posttest": "npm run lint && nsp check" | ||
"posttest": "npm run lint" | ||
}, | ||
@@ -23,3 +23,3 @@ "repository": { | ||
"eslint-config-loopback": "^8.0.0", | ||
"loopback-datasource-juggler": "^3.13.0", | ||
"loopback-datasource-juggler": "^4.1.1", | ||
"mocha": "~5.2.0", | ||
@@ -26,0 +26,0 @@ "nsp": "^3.1.0", |
@@ -19,4 +19,11 @@ | ||
var customerObj; | ||
var customer1, customer2; | ||
it('Should get all documents in empty collection', function(done) { | ||
Customer.all(function(err, customer) { | ||
customer.should.have.length(0); | ||
done(err, customer); | ||
}); | ||
}); | ||
it('Should create a document', function(done) { | ||
@@ -30,3 +37,3 @@ Customer.create({ | ||
}, function(err, customer) { | ||
customerObj = customer; | ||
customer1 = customer; | ||
customer.should.have.property('name', 'Dyaa Eldin'); | ||
@@ -46,2 +53,3 @@ customer.should.have.property('emails').with.lengthOf(2); | ||
}, function(err, customer) { | ||
customer2 = customer; | ||
customer.should.have.property('name', 'Cristian Bullokles'); | ||
@@ -54,4 +62,5 @@ customer.should.have.property('emails').with.lengthOf(1); | ||
it('Should find a document by id', function(done) { | ||
Customer.find({where: {id: customerObj.id}}, function(err, customer) { | ||
Customer.find({where: {id: customer1.id}}, function(err, customer) { | ||
customer.should.be.array; // eslint-disable-line no-unused-expressions | ||
customer.should.containDeep([{id: customer1.id}]); | ||
done(err, customer); | ||
@@ -62,5 +71,7 @@ }); | ||
it('Should get object properties', function(done) { | ||
Customer.find({where: {id: customerObj.id}}, function(err, customer) { | ||
Customer.find({where: {id: customer1.id}}, function(err, customer) { | ||
customer.should.have.length(1); | ||
customer.should.containDeep([{name: 'Dyaa Eldin'}]); | ||
customer.should.containDeep([{name: customer1.name}]); | ||
customer.should.containDeep([{id: customer1.id}]); | ||
done(err, customer); | ||
@@ -73,3 +84,4 @@ }); | ||
customer.should.have.length(2); | ||
customer.should.containDeep([{name: 'Cristian Bullokles'}]); | ||
customer.should.containDeep([{id: customer1.id}]); | ||
customer.should.containDeep([{id: customer2.id}]); | ||
done(err, customer); | ||
@@ -83,2 +95,3 @@ }); | ||
customer.should.containDeep([{age: 26}]); | ||
customer.should.containDeep([{id: customer1.id}]); | ||
done(err, customer); | ||
@@ -89,5 +102,6 @@ }); | ||
it('Should find a document by age equals to 26', function(done) { | ||
Customer.find({where: {age: 27}}, function(err, customer) { | ||
Customer.find({where: {age: customer1.age}}, function(err, customer) { | ||
customer.should.have.length(1); | ||
customer.should.containDeep([{age: 27}]); | ||
customer.should.containDeep([{age: customer1.age}]); | ||
customer.should.containDeep([{id: customer1.id}]); | ||
done(err, customer); | ||
@@ -98,3 +112,3 @@ }); | ||
it('Should Replace attributes for a model instance', function(done) { | ||
Customer.replaceById(customerObj.id, {emails: ['bar@example.com']}, {validate: true}, function(err, customer) { | ||
Customer.replaceById(customer1.id, {emails: ['bar@example.com']}, {validate: true}, function(err, customer) { | ||
customer.should.have.property('emails').with.lengthOf(1); | ||
@@ -106,3 +120,3 @@ done(err, customer); | ||
it('Should delete a document', function(done) { | ||
Customer.destroyAll({id: customerObj.id}, function(err, customer) { | ||
Customer.destroyAll({id: customer1.id}, function(err, customer) { | ||
done(err, customer); | ||
@@ -109,0 +123,0 @@ }); |
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
121417
428
1