-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changed the way cache controllers are implemented
- Loading branch information
1 parent
c6282ca
commit 6379d10
Showing
5 changed files
with
33 additions
and
6 deletions.
There are no files selected for viewing
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,27 @@ | ||
/// <reference path="../../_references.d.ts" /> | ||
import cacheDirector = require('../CacheDirector'); | ||
import MongoDB = require('mongodb'); | ||
|
||
export = IDCacheDirector; | ||
|
||
class IDCacheDirector implements cacheDirector{ | ||
valid(object: { _id: any }) { | ||
return object._id; | ||
return !!object._id; | ||
} | ||
|
||
buildKey(object: { _id: any }) { | ||
return JSON.stringify(object._id); | ||
if (object._id._bsontype == 'ObjectID') | ||
return new MongoDB.ObjectID(object._id.id).toHexString(); | ||
return object._id; | ||
} | ||
|
||
validQuery(conditions) { | ||
return !!conditions._id; | ||
} | ||
|
||
buildQueryKey(conditions) { | ||
if (conditions._id._bsontype == 'ObjectID') | ||
return new MongoDB.ObjectID(conditions._id.id).toHexString(); | ||
return conditions._id; | ||
} | ||
} |