Skip to content

Commit

Permalink
Improve documentation for copyBundledRealmFiles (#4493)
Browse files Browse the repository at this point in the history
* Improve documentation for copyBundledRealmFiles

* Update changelog
  • Loading branch information
Tom Duncalf authored Apr 19, 2022
1 parent bef8c3a commit a5a7bcc
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 5 deletions.
4 changes: 1 addition & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ x.x.x Release notes (yyyy-MM-dd)
* File format: generates Realms with format v22 (reads and upgrades file format v5 or later for non-synced Realm, upgrades file format v10 or later for synced Realms).

### Internal
* <Either mention core version or upgrade>
* <Using Realm Core vX.Y.Z>
* <Upgraded Realm Core from vX.Y.Z to vA.B.C>
* Improved documentation for `Realm.copyBundledRealmFiles`

10.16.0 Release notes (2022-4-12)
=============================================================
Expand Down
22 changes: 21 additions & 1 deletion docs/realm.js
Original file line number Diff line number Diff line change
Expand Up @@ -356,8 +356,28 @@ class Realm {
static exists(config) {}

/**
* Copy all bundled Realm files to app's default file folder.
* Copy any Realm files (i.e. `*.realm`) bundled with the application from the application
* directory into the application's documents directory, so that they can be opened and used
* by Realm. If the file already exists in the documents directory, it will not be
* overwritten, so this can safely be called multiple times.
*
* This should be called before opening the Realm, in order to move the bundled Realm
* files into a place where they can be written to, for example:
*
* ```
* // Given a bundled file, example.realm, this will copy example.realm (and any other .realm files)
* // from the app bundle into the app's documents directory. If the file already exists, it will
* // not be overwritten, so it is safe to call this every time the app starts.
* Realm.copyBundledRealmFiles();
*
* const realm = await Realm.open({
* // This will open example.realm from the documents directory, with the bundled data in.
* path: "example.realm"
* });
* ```
*
* This is only implemented for React Native.
*
* @throws {Error} If an I/O error occured or method is not implemented.
*/
static copyBundledRealmFiles() {}
Expand Down
24 changes: 23 additions & 1 deletion types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -999,7 +999,29 @@ declare class Realm {
static deleteFile(config: Realm.Configuration): void;

/**
* Copy all bundled Realm files to app's default file folder.
* Copy any Realm files (i.e. `*.realm`) bundled with the application from the application
* directory into the application's documents directory, so that they can be opened and used
* by Realm. If the file already exists in the documents directory, it will not be
* overwritten, so this can safely be called multiple times.
*
* This should be called before opening the Realm, in order to move the bundled Realm
* files into a place where they can be written to, for example:
*
* ```
* // Given a bundled file, example.realm, this will copy example.realm (and any other .realm files)
* // from the app bundle into the app's documents directory. If the file already exists, it will
* // not be overwritten, so it is safe to call this every time the app starts.
* Realm.copyBundledRealmFiles();
*
* const realm = await Realm.open({
* // This will open example.realm from the documents directory, with the bundled data in.
* path: "example.realm"
* });
* ```
*
* This is only implemented for React Native.
*
* @throws {Error} If an I/O error occured or method is not implemented.
*/
static copyBundledRealmFiles(): void;

Expand Down

0 comments on commit a5a7bcc

Please sign in to comment.