-
-
Notifications
You must be signed in to change notification settings - Fork 37
add first iteration of inMemoryDatabase with handle possibilities #207
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add first iteration of inMemoryDatabase with handle possibilities #207
Conversation
} | ||
} | ||
|
||
export class ConcurrencyInMemoryDatabaseError extends EmmettError { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CONCERN: @stepaniukm any reason why not use just regular ConcurrencyError
?
} = {}, | ||
): DocumentsCollection<T> => { | ||
const toFullId = (id: string) => `${collectionName}-${id}`; | ||
const ensureCollectionCreated = () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
COMMENT: This is a bit redundant, but I think that's good to have, as we can later on add some other storages, like JSON or local storage or so.
store: (id: string, obj: T) => void; | ||
delete: (id: string) => void; | ||
get: (id: string) => T | null; | ||
export interface DocumentsCollection<T extends Document> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
QUESTION: @stepaniukm, maybe we could already add in this PR find
method that takes a regular filtering predicate? That'd close the basic set of features like find one and find many for read models.
{ operationName: 'replaceOne', collectionName, errors }, | ||
); | ||
}, | ||
handle: ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FIX: @stepaniukm could you add tests for that? You could copy them from Pongo :)
...result, | ||
acknowledged: true, | ||
successful: result.successful, | ||
assertSuccessful: (errorMessage?: string) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FIX: @stepaniukm, could you add tests for that?
}, | ||
{ operationName: 'deleteOne', collectionName, errors }, | ||
); | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SUGGESTION: That's minor, but you can skip this else, as you're retuning the result in IF statement.
} else { | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@stepaniukm looks great, added just a few minor comments and requests for enhancing test coverage, once that's done, I'm more than happy to pull that in 🙂 👍
@stepaniukm, after our discussion, I'm pulling that in, as comments are not show-stoppers. Let's tackle them in the dedicated, follow-up PR 👍 |
This PR introduces the first iteration of in memory database that is more compatible with Pongo, than the first tries. It is supposed to be the 3rd step from the issue: #179