Skip to content
This repository has been archived by the owner on Nov 10, 2023. It is now read-only.

Commit

Permalink
fix: private model properties are private (#24)
Browse files Browse the repository at this point in the history
* fix: private model properties are private

* chore: packge bump
  • Loading branch information
gjuchault committed May 30, 2017
1 parent ec7b50a commit 1fa8b6f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
9 changes: 5 additions & 4 deletions lib/model/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const bindVirtuals = require('./util/bindVirtuals')
const bindRql = require('./util/bindRql')
const generateJoinTableName = require('./util/generateJoinTableName')
const takeEvents = require('./util/takeEvents')
const hiddenProp = require('./util/hiddenProp')
const parse = require('./parse')
const saveAll = require('./saveAll')

Expand Down Expand Up @@ -45,10 +46,10 @@ function createModel (requelize) {
// Create virtual getters
bindVirtuals(Model, this)

this._data = {}
this._pivot = {}
this._validate = true
this._saved = false
hiddenProp(this, '_data', {})
hiddenProp(this, '_pivot', {})
hiddenProp(this, '_validate', true)
hiddenProp(this, '_saved', false)

// Set initial values (must be after getters/setters)
for (const key of Object.keys(initialData)) {
Expand Down
14 changes: 14 additions & 0 deletions lib/model/util/hiddenProp.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
* Create a hidden property
* Useful when printing JSON models
* @param {Object} obj Object
* @param {String} prop Property name
* @param {Object} value Any value
*/
module.exports = (obj, prop, value) => {
Object.defineProperty(obj, prop, {
enumerable: false,
writable: true,
value
})
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "requelize",
"version": "0.9.2",
"version": "0.9.3",
"description": "RethinkDB ORM",
"main": "index.js",
"repository": "https://github.com/buckless/requelize.git",
Expand Down

0 comments on commit 1fa8b6f

Please sign in to comment.