MemoryWorkDb class

In-memory file system implementation.

This implementation stores all data in memory using a Map. It's perfect for:

  • Unit testing
  • Temporary storage
  • Quick prototyping

Note

All data is lost when the application terminates.

Usage

final fs = MemoryWorkDb();
final db = ClientWorkDb.createInstance(fs);

// Use for testing
await db.create(ItemWithId(
  id: 'test-1',
  collection: 'test',
  item: {'data': 'value'},
));
Implemented types

Constructors

MemoryWorkDb()

Properties

hashCode → int
The hash code for this object.
no setterinherited
itemCount → int
Returns the number of items stored.
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

clear() → void
Clears all data from memory.
deleteFile(String path) → Future<void>
Deletes a file at the specified path.
override
deleteFileSync(String path) → void
Deletes a file at the specified path synchronously.
override
deleteFolder(String folderPath) → Future<void>
Deletes a folder and all its contents recursively.
override
deleteFolderSync(String folderPath) → void
Deletes a folder and all its contents recursively, synchronously.
override
exist(String path) → Future<bool>
Checks if a file or folder exists at the specified path.
override
existSync(String path) → bool
Checks if a file or folder exists at the specified path synchronously.
override
getFile(String path) → Future<ItemOutput>
Reads an item from the specified path.
override
getFileSync(String path) → ItemOutput
Reads an item from the specified path synchronously.
override
getPath() → String
override
ls(String dirPath) → Future<List<String>>
Lists all files/items in a directory.
override
lsSync(String dirPath) → List<String>
Lists all files/items in a directory synchronously.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
renameFile(String oldPath, String newPath) → Future<void>
Renames/moves a file from one path to another.
override
renameFileSync(String oldPath, String newPath) → void
Renames/moves a file from one path to another synchronously.
override
toJson() → String
Returns a JSON string representation of all stored data.
toString() → String
A string representation of this object.
inherited
writeFile(String path, Item input) → Future<void>
Writes an item to the specified path.
override
writeFileSync(String path, Item input) → void
Writes an item to the specified path synchronously.
override

Operators

operator ==(Object other) → bool
The equality operator.
inherited