Merge pull request #90 from clems4ever/hotfix-nedb-memflag

[Hotfix] Fix bug while reading Nedb option inMemoryOnly
This commit is contained in:
Clément Michaud 2017-09-21 23:38:01 +02:00 committed by GitHub
commit 83f5302615
3 changed files with 9 additions and 9 deletions

View File

@ -49,9 +49,9 @@ export interface ServerVariables {
class UserDataStoreFactory {
static create(config: Configuration.AppConfiguration): BluebirdPromise<UserDataStore> {
if (config.storage.local) {
const nedbOptions = {
directory: config.storage.local.path,
inMemory: config.storage.local.in_memory
const nedbOptions: Nedb.DataStoreOptions = {
filename: config.storage.local.path,
inMemoryOnly: config.storage.local.in_memory
};
const collectionFactory = CollectionFactoryFactory.createNedb(nedbOptions);
return BluebirdPromise.resolve(new UserDataStore(collectionFactory));

View File

@ -1,11 +1,11 @@
import { ICollectionFactory } from "./ICollectionFactory";
import { NedbCollectionFactory, NedbOptions } from "./nedb/NedbCollectionFactory";
import { NedbCollectionFactory } from "./nedb/NedbCollectionFactory";
import { MongoCollectionFactory } from "./mongo/MongoCollectionFactory";
import { IMongoClient } from "../connectors/mongo/IMongoClient";
export class CollectionFactoryFactory {
static createNedb(options: NedbOptions): ICollectionFactory {
static createNedb(options: Nedb.DataStoreOptions): ICollectionFactory {
return new NedbCollectionFactory(options);
}

View File

@ -10,17 +10,17 @@ export interface NedbOptions {
}
export class NedbCollectionFactory implements ICollectionFactory {
private options: NedbOptions;
private options: Nedb.DataStoreOptions;
constructor(options: NedbOptions) {
constructor(options: Nedb.DataStoreOptions) {
this.options = options;
}
build(collectionName: string): ICollection {
const datastoreOptions = {
const datastoreOptions: Nedb.DataStoreOptions = {
inMemoryOnly: this.options.inMemoryOnly || false,
autoload: true,
filename: (this.options.directory) ? path.resolve(this.options.directory, collectionName) : undefined
filename: (this.options.filename) ? path.resolve(this.options.filename, collectionName) : undefined
};
return new NedbCollection(datastoreOptions);