![require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages](https://cdn.sanity.io/images/cgdhsj6q/production/be8ab80c8efa5907bc341c6fefe9aa20d239d890-1600x1097.png?w=400&fit=max&auto=format)
Security News
require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
@caruuto/api-filestore
Advanced tools
To use this adapter with your API installation, you'll need to add it to your API's dependencies:
$ npm install @caruuto/api-filestore
Configuration settings are defined in JSON files within a /config
directory at the root of your API application. API has provision for multiple configuration files, one for each environment that your API is expected to run under, for example development
and production
.
A post-install script ran when you installed the package from NPM, creating a development configuration file for you at config/filestore.development.json
.
The naming convention for @caruuto/api-filestore
configuration files follows the format filestore.<environment>.json
For example:
filestore.development.json
filestore.production.json
my-api/
config/ # contains environment-specific configuration properties
config.development.json
config.production.json
filestore.development.json
filestore.production.json
main.js # the entry point of the app
package.json
workspace/
collections/ # collection schema files
endpoints/ # custom Javascript endpoints
The contents of the configuration file should be similar to the following:
{
"database": {
"path": "path/to/your/database",
"autosaveInterval": 10000,
"serializationMethod": "pretty"
}
}
Property | Description | Default |
---|---|---|
path | The relative or absolute path to where your database files will be stored | none |
autosaveInterval | The interval, in milliseconds, between database writes to disk | 5000 (5 seconds) |
serializationMethod | The format of the database file on disk. normal is a condensed version of the JSON, pretty is more readable | normal |
// explicit
{'Name': { '$eq' : 'Odin' }}
// implicit (assumes equality operator)
{'Name': 'Odin'}
not equal test
{'legs': { '$ne' : 8 }}
// pass in raw regex
var results = coll.find({Name: {$regex: /din/}})
// or pass in string pattern only
results = coll.find({Name: {$regex: 'din'}})
// or pass in [pattern, options] string array
results = coll.find({Name: {$regex: ['din', 'i']}})
If using regex operator within a named transform or dynamic view filter, it is best to use the latter two examples since raw regex does not seem to serialize/deserialize well.
var users = db.addCollection("users");
users.insert({ name : 'odin' });
users.insert({ name : 'thor' });
users.insert({ name : 'svafrlami' });
// match users with name in array set ['odin' or 'thor']
{ 'name' : { '$in' : ['odin', 'thor'] } }
// match users with count value between 50 and 75
{ count : { '$between': [50, 75] } }
var users = db.addCollection("users");
users.insert({ name : 'odin', weapons : ['gungnir', 'draupnir']});
users.insert({ name : 'thor', weapons : ['mjolnir']});
users.insert({ name : 'svafrlami', weapons : ['tyrfing']});
users.insert({ name : 'arngrim', weapons : ['tyrfing']});
// returns 'svafrlami' and 'arngrim' documents
{ 'weapons' : { '$contains' : 'tyrfing' } }
// returns 'svafrlami', 'arngrim', and 'thor' documents
{ 'weapons' : { '$containsAny' : ['tyrfing', 'mjolnir'] } }
// returns 'svafrlami' and 'arngrim'
{ 'weapons' : { '$containsNone' : ['gungnir', 'mjolnir'] } }
fetch documents matching both sub-expressions
{
'$and': [{
'Age' : {
'$gt': 30
}
},{
'Name' : 'Thor'
}]
}
fetch documents matching any of the sub-expressions
{
'$or': [{
'Age' : {
'$gte': '40'
}
},{
'Name' : 'Thor'
}]
}
FAQs
A JSON datastore adapter for API
We found that @caruuto/api-filestore demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.