forked from mongodb/docs-realm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
544fc5a
commit 1260018
Showing
9 changed files
with
138 additions
and
15 deletions.
There are no files selected for viewing
Empty file.
7 changes: 7 additions & 0 deletions
7
...ce/includes/api-details/csharp/manage-files/reduce-file-size-compact-method.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Alternatively, you can compact a realm file without first obtaining an instance | ||
to the realm by calling the | ||
:dotnet-sdk:`Compact() <reference/Realms.Realm.html#Realms_Realm_Compact_Realms_RealmConfigurationBase_>` | ||
method. The following example shows how to do this: | ||
|
||
|
||
The ``Compact`` method will return true if the operation is successful. |
14 changes: 14 additions & 0 deletions
14
source/includes/api-details/dart/manage-files/reduce-file-size-compact-method.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
You can compact a realm file by calling :flutter-sdk:`Realm.compact() | ||
<realm/Realm/compact.html>`. This method takes a :flutter-sdk:`Configuration | ||
<topics/Configuration-topic.html>` as an argument. When you use this method, | ||
the device must have enough free space to make a copy of the realm. | ||
|
||
``Realm.compact()`` obtains an instance of the realm, and opens it to | ||
trigger any schema version upgrades, file format upgrades, migration and | ||
initial data callbacks. Upon successfully opening the realm and performing | ||
these operations, this method then compacts the realm. | ||
|
||
If successful, a call to ``Realm.compact()`` returns ``true``. | ||
|
||
Do not call this method from inside a transaction. You also cannot compact an | ||
open realm. |
8 changes: 8 additions & 0 deletions
8
source/includes/api-details/java/manage-files/reduce-file-size-compact-method.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
You can remove unused space by **compacting** the realm file by manually | ||
calling :java-sdk:`compactRealm() | ||
<io/realm/Realm.html#compactRealm-io.realm.RealmConfiguration->` | ||
|
||
.. important:: Compact All Production Applications | ||
|
||
Every production application should implement compacting to | ||
periodically reduce realm file size. |
4 changes: 4 additions & 0 deletions
4
...ncludes/api-details/javascript/manage-files/reduce-file-size-compact-method.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
You can compact a realm file whenever you'd like by calling | ||
the :js-sdk:`compact() <Realm.html#compact>` method: | ||
|
||
The ``compact()`` method will return true if the operation is successful. |
12 changes: 3 additions & 9 deletions
12
.../api-details/javascript/manage-files/reduce-file-size-on-launch-description.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,3 @@ | ||
Use the :cpp-sdk:`should_compact_on_launch() <structrealm_1_1internal_1_1bridge_1_1realm_1_1config.html>` | ||
method on the database configuration to attempt to compact the database. | ||
Specify conditions to execute this method, such as: | ||
|
||
- The size of the file on disk | ||
- How much free space the file contains | ||
|
||
The following example shows setting the conditions to compact a realm if the | ||
file is above 100 MB and 50% or less of the space in the realm file is used. | ||
You can configure Realm to check the realm file each time it is opened | ||
by specifying a :js-sdk:`shouldCompact <Realm.html#~Configuration>` function | ||
for the configuration. The following code example shows how to do this: |
50 changes: 50 additions & 0 deletions
50
source/includes/sdk-examples/manage-files/reduce-file-size-compact-method.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
.. tabs-drivers:: | ||
|
||
tabs: | ||
- id: cpp-sdk | ||
content: | | ||
|
||
.. literalinclude:: /examples/MissingPlaceholders/api.cpp | ||
:language: cpp | ||
|
||
- id: csharp | ||
content: | | ||
|
||
.. literalinclude:: /examples/generated/dotnet/Compact.snippet.manual-compact.cs | ||
:language: csharp | ||
|
||
- id: dart | ||
content: | | ||
|
||
.. literalinclude:: /examples/generated/flutter/compact_realm_test.snippet.compact-static-method.dart | ||
:language: dart | ||
|
||
- id: java | ||
content: | | ||
|
||
.. literalinclude:: /examples/MissingPlaceholders/example.java | ||
:language: java | ||
|
||
- id: javascript | ||
content: | | ||
|
||
.. literalinclude:: /examples/generated/node/compacting.snippet.compactNode.js | ||
:language: javascript | ||
|
||
- id: kotlin | ||
content: | | ||
|
||
.. literalinclude:: /examples/generated/kotlin/Compacting.snippet.compactOnLaunch.kt | ||
:language: kotlin | ||
|
||
- id: objectivec | ||
content: | | ||
|
||
.. literalinclude:: /examples/generated/code/start/Compacting.snippet.compacting.m | ||
:language: objectivec | ||
|
||
- id: swift | ||
content: | | ||
|
||
.. literalinclude:: /examples/generated/code/start/Compacting.snippet.async-compact.swift | ||
:language: swift |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters