zimki | documentation | search
 
Zimki Documentation - Zimki Class

Instances of Zimki classes are persistable in the Zimki object store. These classes have names, and top-level objects are created in your JavaScript context for each class. These object will have methods defined on them to allow you to create, delete and search for instances of these classes. For instance, suppose that I have used the portal to create a new persistable class called MyClass. I can create an instance in JavaScript space, then change it's properties, and save it:

  var instance = MyClass.create();
  instance.my_name = "Rapunzel";
  instance.save();

Likewise, there are calls to search for instances:

  // search for all instances called 'Rapunzel':
  var results = MyClass.search({ my_name:'Rapunzel' });

  // get the first one
  var first = results[0];

You can also retrieve an instance directly by it's ID:

  var rapunzel = MyClass.get( first.id );

And you can use the search terms in the get call:

  // get the first instance called Rapunzel
  var rapunzel = MyClass.get({ my_name:'Rapunzel' });

To delete a class:

  // delete poor old Rapunzel
  rapunzel.deleteInstance();

New persistable classes can be created by using zimki.persist.

  zimki.persist.create("AnotherClass");
  var anotherInstance = AnotherClass.create();

Calls to zimki.persist.create will fail if the class already exists.

Properties

Methods