Untitled

 avatar
user_9363972
javascript
a year ago
709 B
6
Indexable
import Realm, { BSON } from "realm";

export class Note extends Realm.Object {
  _id!: String;
  description!: String;
  isComplete!: Boolean;
  createdAt!: Date;

  static primaryKey = "_id";
  static schema = {
    name: "Task",
    primaryKey: "_id",
    properties: {
      _id: "uuid",
      description: "string",
      createdAt: {
        type: "date",
        default: new Date(),
      },
      isComplete: {
        type: "bool",
        default: false,
        indexed: true,
      },
    },
  };

  constructor(realm: any, description: string) {
    console.log("in constructor");
    super(realm, {
      _id: new BSON.UUID(),
      description,
    });
  }
}
Editor is loading...
Leave a Comment