[Hotfix] Fix bug while reading Nedb option inMemoryOnly

pull/90/head
Clement Michaud 2017-09-21 22:17:55 +02:00
parent 9ac2c808ec
commit e9a4ebca38
3 changed files with 9 additions and 9 deletions

View File

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

View File

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

View File

@ -10,17 +10,17 @@ export interface NedbOptions {
} }
export class NedbCollectionFactory implements ICollectionFactory { export class NedbCollectionFactory implements ICollectionFactory {
private options: NedbOptions; private options: Nedb.DataStoreOptions;
constructor(options: NedbOptions) { constructor(options: Nedb.DataStoreOptions) {
this.options = options; this.options = options;
} }
build(collectionName: string): ICollection { build(collectionName: string): ICollection {
const datastoreOptions = { const datastoreOptions: Nedb.DataStoreOptions = {
inMemoryOnly: this.options.inMemoryOnly || false, inMemoryOnly: this.options.inMemoryOnly || false,
autoload: true, 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); return new NedbCollection(datastoreOptions);