Untitled

 avatar
user_9363972
javascript
a month ago
709 B
4
Indexable
Never
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,
    });
  }
}
Leave a Comment