Update API docs with info about constructors

This commit is contained in:
Scott Kyle 2016-03-04 14:13:28 -08:00
parent 42cdf9daad
commit 52f296c3ac

View File

@ -37,8 +37,7 @@ class Realm {
/** /**
* Create a new Realm object of the given type and with the specified properties. * Create a new Realm object of the given type and with the specified properties.
* @param {string} type - The type of object as specified by its `name` in the * @param {Realm~ObjectType} type - The type of Realm object to create.
* {@link Realm~ObjectSchema ObjectSchema} definition.
* @param {Object} properties - Property values for all required properties without a * @param {Object} properties - Property values for all required properties without a
* default value. * default value.
* @param {boolean} [update=false] - Signals that an existing object with matching primary key * @param {boolean} [update=false] - Signals that an existing object with matching primary key
@ -61,12 +60,11 @@ class Realm {
/** /**
* Returns all objects of the given `type` in the Realm. * Returns all objects of the given `type` in the Realm.
* @param {string} type - The type of object as specified by its `name` in the * @param {Realm~ObjectType} type - The type of Realm objects to retrieve.
* {@link Realm~ObjectSchema ObjectSchema} definition.
* @throws {Error} If type passed into this method is invalid. * @throws {Error} If type passed into this method is invalid.
* @returns {Realm.Results} that will live-update as objects are created and destroyed. * @returns {Realm.Results} that will live-update as objects are created and destroyed.
*/ */
objects(type, query, ...arg) {} objects(type) {}
/** /**
* Add a listener `callback` for the specified event `name`. * Add a listener `callback` for the specified event `name`.
@ -116,12 +114,20 @@ Realm.defaultPath;
* @type {Object} * @type {Object}
* @property {string} [path={@link Realm.defaultPath}] - The path to the file where the * @property {string} [path={@link Realm.defaultPath}] - The path to the file where the
* Realm database should be stored. * Realm database should be stored.
* @property {Realm~ObjectSchema[]} [schema] - Specifies all the object types in the realm. * @property {Array<Realm~ObjectClass|Realm~ObjectSchema>} [schema] - Specifies all the
* **Required** when first creating realm at this `path`. * object types in this Realm. **Required** when first creating realm at this `path`.
* @property {number} [schemaVersion] - **Required** (and must be incremented) after * @property {number} [schemaVersion] - **Required** (and must be incremented) after
* changing the `schema`. * changing the `schema`.
*/ */
/**
* Realm objects will inherit methods, getters, and setters from the `prototype` of this
* constructor.
* @typedef Realm~ObjectClass
* @type {Class}
* @property {Realm~ObjectSchema} schema - Static property specifying object schema information.
*/
/** /**
* @typedef Realm~ObjectSchema * @typedef Realm~ObjectSchema
* @type {Object} * @type {Object}
@ -143,6 +149,14 @@ Realm.defaultPath;
* @property {boolean} [optional] - Signals if this property may be assigned `null` or `undefined`. * @property {boolean} [optional] - Signals if this property may be assigned `null` or `undefined`.
*/ */
/**
* The type of an object may either be specified as a string equal to the `name` in a
* {@link Realm~ObjectSchema ObjectSchema} definition, **or** a constructor that was specified
* in the {@link Realm~Configuration configuration} `schema`.
* @typedef Realm~ObjectType
* @type {string|Realm~ObjectClass}
*/
/** /**
* A property type may be specified as one of the standard builtin types, or as an object type * A property type may be specified as one of the standard builtin types, or as an object type
* inside the same schema. * inside the same schema.