You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Importing structured data into the database can be done the following way:
143
143
```ts
144
-
// pass a filename, the import will be asynchronous
145
-
awaitdb.importJson(filename);
146
144
// pass the object directly, the import will be synchronous
147
-
db.importJson({key: "value"});
145
+
db.importJSON({key: "value"});
148
146
```
149
-
In both cases, existing entries in the DB will not be deleted but will be overwritten if they exist.
147
+
Existing entries in the DB will not be deleted but will be overwritten if they exist.
150
148
151
-
Exporting JSON files is also possible:
149
+
Exporting the data as a JSON object is also possible:
152
150
```ts
153
-
awaitdb.exportJson(filename[, options]);
151
+
const json =db.toJSON();
154
152
```
155
-
The file will be overwritten if it exists. The 2nd options argument can be used to control the file formatting. Since `fs-extra`'s `writeJson` is used under the hood, take a look at that [method documentation](https://github.com/jprichardson/node-fs-extra/blob/master/docs/writeJson.md) for details on the options object.
156
153
157
154
## Changelog
158
155
159
156
<!--
160
157
Placeholder for next release:
161
158
### __WORK IN PROGRESS__
162
159
-->
160
+
### __WORK IN PROGRESS__
161
+
* BREAKING: Drop support for Node.js versions older than v22 (#529)
162
+
* BREAKING: Removed `exportJson` method in favor of `toJSON`
163
+
* BREAKING: Renamed `importJson` method to `importJSON`. Importing from a file is no longer supported. Read the file yourself if you need this functionality.
164
+
* Filesystem access is now done using the native `fs.promises` instead of `fs-extra`
165
+
* The package is now a hybrid ESM/CJS package (#529)
0 commit comments