Document.prototype.$pk >= 1.1.0
Description
Reference to the primary key field
Flags
- Client
- This will also be available on the client-side, in the browser.
Examples
Refer to the primary key of a MongoDB document
If the datasource of your model is MongoDB (or any other datasource that uses ObjectIDs), $pk
will refer to _id
// Get the model
let page_model = Model.get('Page');
// Get a document
let page = await page_model.find('first');
// The `$pk` property will now refer to `_id`
page.$pk === page._id;
Comments