Skip to content

Commit

Permalink
Test moving out example boxes
Browse files Browse the repository at this point in the history
  • Loading branch information
cbullinger committed May 20, 2024
1 parent 3b744c1 commit 50afc0e
Show file tree
Hide file tree
Showing 35 changed files with 1,148 additions and 805 deletions.
31 changes: 30 additions & 1 deletion examples/node/v12/__tests__/models/rql-data-models.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,33 @@
import Realm, { BSON, ObjectSchema } from "realm";

// Models for embedded objects & dot notation queries
export class Office extends Realm.Object {
name!: string;
address!: Address;
static schema: ObjectSchema = {
name: "Office",
properties: {
name: "string",
address: "Address",
},
};
}

export class Address extends Realm.Object {
name!: string;
street!: string;
zipcode!: number;
static schema: ObjectSchema = {
name: "Address",
embedded: true,
properties: {
name: "string",
street: "string",
zipcode: "int",
},
};
}

// :snippet-start: rql-data-models
export class Item extends Realm.Object<Item> {
_id!: BSON.ObjectId;
Expand Down Expand Up @@ -27,13 +55,13 @@ export class Item extends Realm.Object<Item> {
primaryKey: "_id",
};
}

export class Project extends Realm.Object<Project> {
_id!: BSON.ObjectId;
name!: string;
items!: Realm.List<Item>;
quota?: number;
comments?: Realm.Dictionary<string>;
projectLocation?: Office;

static schema: ObjectSchema = {
name: "Project",
Expand All @@ -43,6 +71,7 @@ export class Project extends Realm.Object<Project> {
items: "Item[]",
quota: "int?",
comments: "string?{}",
projectLocation: "Office?",
},
primaryKey: "_id",
};
Expand Down
Loading

0 comments on commit 50afc0e

Please sign in to comment.