swift-database
Advanced tools
Comparing version 1.0.0 to 1.1.0
@@ -15,3 +15,3 @@ import JSONFile from './JSONFile'; | ||
*/ | ||
getAll(): TableDocument[]; | ||
get all(): TableDocument[]; | ||
/** | ||
@@ -98,4 +98,4 @@ * → Get a document by its id | ||
*/ | ||
push(documentId: string, propertyKey: string, value: any): TableDocument; | ||
push(documentId: string, propertyKey: string, ...items: any[]): TableDocument; | ||
} | ||
export {}; |
@@ -19,3 +19,3 @@ "use strict"; | ||
get size() { | ||
return this.getAll().length; | ||
return this.all.length; | ||
} | ||
@@ -25,3 +25,3 @@ /** | ||
*/ | ||
getAll() { | ||
get all() { | ||
const documentsData = this._file.data[this.name]; | ||
@@ -43,3 +43,3 @@ return documentsData.map((documentData) => new TableDocument_1.default(documentData)); | ||
findOne(predicate) { | ||
return this.getAll().find(predicate); | ||
return this.all.find(predicate); | ||
} | ||
@@ -51,3 +51,3 @@ /** | ||
findMany(predicate) { | ||
return this.getAll().filter(predicate); | ||
return this.all.filter(predicate); | ||
} | ||
@@ -242,3 +242,3 @@ /** | ||
*/ | ||
push(documentId, propertyKey, value) { | ||
push(documentId, propertyKey, ...items) { | ||
const documentToUpdate = this.getById(documentId); | ||
@@ -252,4 +252,4 @@ if (!documentToUpdate) | ||
const fileData = this._file.data; | ||
fileData[this.name].find((documentData) => documentData._id === documentToUpdate.id)[propertyKey].push(value); | ||
documentToUpdate.value[propertyKey].push(value); | ||
fileData[this.name].find((documentData) => documentData._id === documentToUpdate.id)[propertyKey].push(items); | ||
documentToUpdate.value[propertyKey].push(items); | ||
this._file.updateData(fileData); | ||
@@ -256,0 +256,0 @@ return documentToUpdate; |
{ | ||
"name": "swift-database", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "A light-weight module to interact with your local JSON database.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
34624