UNPKG

als-store

Version:

Library for streamlined file management and advanced data caching, featuring intelligent file searching, dynamic cache control, and flexible file operations

37 lines (29 loc) 1.21 kB
### Method: `create(name, value)` #### Overview: The `create` method in the `Store` class is used for creating new file within the store. Under the hood, it creates new instance of File class and return it. #### Usage with `dir` Method: - **Setting Directory Path**: The `create` method can be preceded by the `dir` method to specify the path to the directory that is to be saved. - **Example**: ```js store.dir('some/path/to/dir').create('filename', 'value'); ``` #### Method Implementation: - **Parameters**: - `name` (String/Object, required): The current name of the file or parameters if schema presented. - Can include directory path - like `some/dir/name.ext` - **Error Handling**: - if name is object and schema presented, error validation functions can throw errors. - if name is string and it's length less than 1 or more than 255 - `value` (String, optional): The value of the files. #### Examples Using filename: ```js const file = store.create('some.txt','some value') file.save() ``` Using object: ```js // schema {name:String,ext:String} const file = store.create({name:'some',ext:'txt'},'some value') file.save() ```