-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added extra basic nested object support (#6)
* feat: added extra basic nested object feature No search. * test: added finding doc tests * chore(package): bump to 2.1.0 * test: added remove to benchmark * fix: basic verification on elements being returned * fix(getAll): deal with resolvedP being array. * test: correctly perform specific query
- Loading branch information
1 parent
d36136f
commit 3a00b49
Showing
11 changed files
with
127 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
module.exports = async function getDocument(identifier){ | ||
return JSON.parse(JSON.stringify(this.documents[identifier])); | ||
} | ||
const doc = this.documents[identifier]; | ||
if(doc){ | ||
return JSON.parse(JSON.stringify(this.documents[identifier])); | ||
} | ||
return {_id:identifier}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
const {expect} = require('chai'); | ||
const {SBTree} = require('../..'); | ||
describe('E2E - Classic UseCase', function suite() { | ||
describe('RegUser DB', () => { | ||
const customTree = new SBTree({ | ||
order: 3, | ||
}); | ||
const alex = { | ||
_id: "5d9d74a2668f032206e4dc01", | ||
name:"Alex", | ||
infos:{ | ||
job:{ | ||
sector: "IT" | ||
} | ||
} | ||
}; | ||
it('should allow to insert documents with basic nested support', async function () { | ||
await customTree.insertDocuments(alex); | ||
}); | ||
it('should allow to find the document', async function () { | ||
const doc = await customTree.findDocuments({name:"Alex"}); | ||
expect(doc).to.deep.equal([alex]) | ||
}); | ||
it('should not be able to find document on nested',async function () { | ||
// May be we should warn user in some way ? | ||
const doc = await customTree.findDocuments({infos:{job:{sector:"IT"}}}); | ||
expect(doc).to.deep.equal([]); | ||
}); | ||
}); | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters