Skip to content

Commit

Permalink
Merge branch 'master' into docsp-32067-create-page
Browse files Browse the repository at this point in the history
  • Loading branch information
cbullinger authored Oct 6, 2023
2 parents b4c41b3 + 9d8f1b8 commit 4818d77
Show file tree
Hide file tree
Showing 324 changed files with 4,201 additions and 1,538 deletions.
43 changes: 40 additions & 3 deletions docs-release-notes.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,40 @@
# September 29, 2023

## Kotlin SDK

- Realm/Model Data

- Define an Object Model: Wording improvements around embedded objects. Update code example.
- Relationships: Wording improvements, code example updates, and link cleanup.
- Supported Types: Add details about optional properties and default values.
- Property Annotations: Wording improvements, code example updates, and link cleanup.

- Manage Users
- Landing Page: Convert the landing page to a container page with no content. Move content onto relevant child pages.
- Create & Authenticate Users: Move info on creating users onto the "Authenticate Users" page. Rename it to "Create and Authenticate Users."
- Delete Users: Rename page from "Create and Delete Users" to "Delete Users." Move content about creating users off of page.
- Manage Custom User Data: Rename title from "Custom User Data" to match verb-based page names. Minor rewrites.
- Manage User Metadata: Rename title from "user Metadata" to match verb-based page names. Minor rewrites.
- Manage Multi-User Apps: New page with tested, Bluehawked code examples describing how to manage multiple users on a device.

## .NET SDK

- Internal: Bump Nuget package version. Update unit test.

## Node.js SDK

- Model Data/Define a Realm Object Model: New "Set a Full-Text Search Index" section with tested, Bluehawked code example showing how to set a Full-Text Search index on a property.
- CRUD/Query Data: New "Filter with Full-Text Search" section with tested, Bluehawked code examples describing how to query with Full-Text Search.

## React Native SDK

- Sync Data/Handle Sync Errors: Add an example of handling a `CompensatingWriteError`.

## Other

- Add an App Services docs-wide banner with a link to the blog post announcing that "Realm is now Atlas Device SDK."
- Add manual facet tags with relevant keywords to improve docs search results.

# September 22, 2023

## Flutter SDK
Expand All @@ -10,12 +47,12 @@
- Realm/Model Data
- Landing Page: Unlist landing page and turn it into a container in the TOC.
- Define an Object Model: Update code examples and move relevant content from landing page to this page.
- Sync Device Data/Manage Sync Session: Add details for ``.reconnect()`` method, which manually triggers an attempt to reconnect to Sync.
- Atlas App Services/Connect to App Services: Add information about custom HTTP headers and additional configuration details about ``app.close()``.
- Sync Device Data/Manage Sync Session: Add details for `.reconnect()` method, which manually triggers an attempt to reconnect to Sync.
- Atlas App Services/Connect to App Services: Add information about custom HTTP headers and additional configuration details about `app.close()`.

## .NET SDK

- Sync Data/Manage Flexible Sync Subscriptions: Add information about the Flexible Sync ``SubscribeAsync`` API.
- Sync Data/Manage Flexible Sync Subscriptions: Add information about the Flexible Sync `SubscribeAsync` API.

## Node.js SDK

Expand Down
6 changes: 3 additions & 3 deletions examples/dotnet/Examples/Compact.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ public async Task Compacts()
* the realm file
*/
// Compact if the file is over 100MB in size or more
// Compact if the file is over 100MB in size and less
// than 50% 'used'
var oneHundredMB = 100 * 1024 * 1024;
return (totalBytes > (double)oneHundredMB) ||
((double)usedBytes / totalBytes > 0.5);
return (totalBytes > (double)oneHundredMB) &&
((double)usedBytes / totalBytes < 0.5);
}
};
var realm = await Realm.GetInstanceAsync(config);
Expand Down
10 changes: 8 additions & 2 deletions examples/ios/Examples/Logging.swift
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,10 @@ class Logging: XCTestCase {
// Create an instance of `Logger` and define the log function to invoke.
let logger = Logger(level: .detail) { level, message in
logs += "\(Date.now) \(level) \(message) \n" // :remove:
"REALM DEBUG: \(Date.now) \(level) \(message) \n"
// You may pass log information to a logging service, or
// you could simply print the logs for debugging. Define
// the log function that makes sense for your application.
print("REALM DEBUG: \(Date.now) \(level) \(message) \n")
}
// :snippet-end:
Logger.shared = logger
Expand Down Expand Up @@ -96,7 +99,10 @@ class Logging: XCTestCase {
// :snippet-start: set-default-logger
let logger = Logger(level: .info) { level, message in
logs += "\(Date.now) \(level) \(message) \n" // :remove:
"REALM DEBUG: \(Date.now) \(level) \(message) \n"
// You may pass log information to a logging service, or
// you could simply print the logs for debugging. Define
// the log function that makes sense for your application.
print("REALM DEBUG: \(Date.now) \(level) \(message) \n")
}

// Set a logger as the default
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package com.mongodb.realm.realmkmmapp

import io.realm.kotlin.ext.realmListOf
import io.realm.kotlin.types.RealmInstant
import io.realm.kotlin.types.RealmList
import io.realm.kotlin.types.RealmObject
import io.realm.kotlin.types.annotations.PrimaryKey
import org.mongodb.kbson.ObjectId

// :replace-start: {
// "terms": {
// "ExampleSyncObject_": "",
// "SyncTask": "Task"
// }
// }

/*
******** Object Models to use in Sync examples and tests *********
*/

class Toad : RealmObject {
@PrimaryKey
var _id: ObjectId = ObjectId()
var name: String = ""
}

// :snippet-start: flexible-sync-models
class SyncTask : RealmObject {
@PrimaryKey
var _id: ObjectId = ObjectId()
var taskName: String = ""
var assignee: String? = null
var completed: Boolean = false
var progressMinutes: Int = 0
var dueDate: RealmInstant? = null
}

class Team : RealmObject {
@PrimaryKey
var _id: ObjectId = ObjectId()
var teamName: String = ""
var tasks: RealmList<SyncTask>? = realmListOf()
var members: RealmList<String> = realmListOf()
}
// :snippet-end:


/*
** Used on Add Sync to App page **
*/

// :snippet-start: sync-to-do-model
class ExampleSyncObject_List : RealmObject {
@PrimaryKey
var _id: ObjectId = ObjectId()
var name: String = ""
var ownerId: String = ""
var items: RealmList<ExampleSyncObject_Item> = realmListOf()
}

class ExampleSyncObject_Item : RealmObject {
@PrimaryKey
var _id: ObjectId = ObjectId()
var name: String = ""
var complete: Boolean = false
}
// :snippet-end:

// :replace-end:
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ import io.realm.kotlin.mongodb.subscriptions
import io.realm.kotlin.mongodb.sync.*
import io.realm.kotlin.mongodb.syncSession
import io.realm.kotlin.query.RealmResults
import io.realm.kotlin.types.RealmInstant
import io.realm.kotlin.types.RealmList
import io.realm.kotlin.types.RealmObject
import io.realm.kotlin.types.annotations.PrimaryKey
import org.mongodb.kbson.ObjectId
import kotlin.test.Test
import kotlin.test.assertEquals
Expand All @@ -34,36 +30,85 @@ import kotlin.time.Duration.Companion.seconds
// "yourFlexAppId": "YOUR_APP_ID",
// "strategy2": "clientResetStrategy",
// "strategy3": "clientResetStrategy",
// "hideNotReusingAnonymousUser": "Credentials.anonymous()",
// "ExampleSyncObject_": "",
// "SyncTask": "Task"
// }
// }
class SyncTest: RealmTest() {
@Test
fun addSyncToAppTest() {
val hideNotReusingAnonymousUser = Credentials.anonymous(reuseExisting = false)

class Toad : RealmObject {
@PrimaryKey
var _id: ObjectId = ObjectId()
var name: String = ""
}

// :snippet-start: flexible-sync-models
class SyncTask : RealmObject {
@PrimaryKey
var _id: ObjectId = ObjectId()
var taskName: String = ""
var assignee: String? = null
var completed: Boolean = false
var progressMinutes: Int = 0
var dueDate: RealmInstant? = null
}
// :snippet-start: connect-to-backend
// Replace `YOUR_APP_ID` with your Atlas App ID
val app = App.create(yourFlexAppId)
// :snippet-end:
runBlocking {
// :snippet-start: authenticate-user
// Authenticate the Atlas App Services user
val myAuthenticatedUser = app.login(hideNotReusingAnonymousUser)
// :snippet-end:
// :snippet-start: define-synced-realm
// Define the configuration for the synced realm
val config =
// Pass the authenticated user and the set of
// all objects types you want to be able to sync
SyncConfiguration.Builder(
user = myAuthenticatedUser,
schema = setOf(ExampleSyncObject_List::class, ExampleSyncObject_Item::class)
)
// Define an initial subscription with queries that include
// the user's lists with incomplete items
.initialSubscriptions{ realm ->
add(realm.query<ExampleSyncObject_List>("ownerId == $0", myAuthenticatedUser.id),
name = "user-lists"
)
add(realm.query<ExampleSyncObject_Item>("complete = false"),
name = "incomplete-items"
)
}
.build()
// :snippet-end:

class Team : RealmObject {
@PrimaryKey
var _id: ObjectId = ObjectId()
var teamName: String = ""
var tasks: RealmList<SyncTask>? = realmListOf()
var members: RealmList<String> = realmListOf()
// :snippet-start: open-synced-realm
// Open the synced realm with the defined configuration
val realm = Realm.open(config)
Log.v("Successfully opened synced realm: ${realm.configuration.name}")
// Wait for initial subscriptions to sync to Atlas
realm.subscriptions.waitForSynchronization()
// :snippet-end:
val oid = ObjectId()
// :snippet-start: write-to-synced-realm
// Write ExampleSyncObject_List and ExampleSyncObject_Item objects to the synced realm
// Objects that match the subscription query are synced to Atlas
realm.write {
val list = ExampleSyncObject_List().apply {
_id = oid // :remove:
name = "My Todo List"
ownerId = myAuthenticatedUser.id
items.add(ExampleSyncObject_Item().apply {
name = "Check email"
complete = false
})
}
copyToRealm(list)
}
realm.syncSession.uploadAllLocalChanges(30.seconds)
// :snippet-end:
realm.write {
val todo = query<ExampleSyncObject_List>().find()
assertEquals(oid, todo[0]._id)
assertEquals(1, todo.size)
assertEquals("Check email", todo[0].items[0].name)
delete(todo)
assertEquals(0, todo.size)
}
myAuthenticatedUser.delete()
realm.close()
app.close()
}
}
// :snippet-end:

@Test
fun openASyncedRealmTest() {
Expand Down
4 changes: 2 additions & 2 deletions examples/node/legacy/Examples/asymmetric-sync.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Realm, { BSON } from "realm";
import Realm, { BSON, ObjectSchema } from "realm";

const app = new Realm.App({ id: "js-flexible-oseso" });

Expand All @@ -10,7 +10,7 @@ class WeatherSensor extends Realm.Object<WeatherSensor> {
barometricPressureInHg!: number;
windSpeedInMph!: number;

static schema = {
static schema: ObjectSchema = {
name: "WeatherSensor",
// sync WeatherSensor objects one way from your device
// to your Atlas database.
Expand Down
Loading

0 comments on commit 4818d77

Please sign in to comment.