Hi,
I’m using Ottoman 1.0.6 with couchbase node SKD 2.6.7
here is my model:
const Ottoman = require("ottoman");
const AssetModel = Ottoman.model("Asset", {
activeStatus: { type: "boolean", default: true },
archiveStatus: { type: "boolean", default: false },
_changeTimestamp: {type: "integer", default: Date.now() },
parameters: {
asset_name: { type: "string" },
asset_name_ts: { type: "integer", default: Date.now() },
asset_description: { type: "string" },
asset_description_ts: { type: "integer", default: Date.now() },
asset_typeName: { type: "string" },
asset_typeName_ts: { type: "integer", default: Date.now() },
asset_modelName: { type: "string" },
asset_modelName_ts: { type: "integer", default: Date.now() },
asset_connectionStatus: { type: "integer" },
asset_connectionStatus_ts: { type: "integer", default: Date.now() },
asset_operationStatus: { type: "integer" },
asset_operationStatus_ts: { type: "integer", default: Date.now() },
asset_layerName: { type: "string" },
asset_layerName_ts: { type: "integer", default: Date.now() },
asset_currentUptime: { type: "integer" },
asset_currentUptime_ts: { type: "integer", default: Date.now() },
asset_currentDowntime: { type: "integer" },
asset_currentDowntime_ts: { type: "integer", default: Date.now() },
asset_currentOEE: { type: "integer" },
asset_currentOEE_ts: { type: "integer", default: Date.now() }
},
references: {
assetTypeId: { ref: "AssetType" },
assetModelId: { ref: "AssetModel" },
layerId: { ref: "Layer" }
}
});
So here is my problem:
When I’m saving the model, then I get this saved:
{
"_type": "Asset",
"activeStatus": true,
"archiveStatus": false,
"_changeTimestamp": 1575310192938,
"parameters": {
"asset_name": "MyAsset001",
"asset_description": "This is the Asset Description",
"asset_typeName": "Collaborative",
"asset_modelName": "Model 1234",
"asset_connectionStatus": 1,
"asset_operationStatus": 2,
"asset_layerName": "Layer123",
"asset_currentUptime": 1234,
"asset_currentDowntime": 12,
"asset_currentOEE": 90
},
"references": {
"assetTypeId": {
"_type": "AssetType",
"$ref": "19de5023-973f-4142-9a2a-8b4edbb6a1af"
},
"layerId": {
"_type": "Layer",
"$ref": "a0f22434-edd8-4716-b6e0-ff44e1d7cb61"
},
"assetModelId": {
"_type": "AssetModel",
"$ref": "3bdd1fb5-a5bc-45c7-8b88-cbd77604f1e0"
}
},
"_id": "06876530-a56b-474d-973e-6ed5c5bcabaf"
}
So where in the Model Definition the property name is _changeTimestamp and the value is “default: Date.now()” it got executed and if I didn’t provide any integer than I got the Timestamp which is fine.
But under the property name “parameters” there are a lot of similar lines where I desire to get the same “default” values what I didn’t get.
Is there any solution that I can get the default values in the deeper levels also like at the top level?