Skip to content

Instantly share code, notes, and snippets.

@jpotts
Last active August 29, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jpotts/2a7613be75681ce5b942 to your computer and use it in GitHub Desktop.
Save jpotts/2a7613be75681ce5b942 to your computer and use it in GitHub Desktop.
Creating content in Cloud CMS using the Gitana JavaScript driver
var Gitana = require('gitana');
var repoId = 'someRepoId';
conn = Gitana.connect({
}, function(err) {
if (err) console.log(err);
});
conn.readRepository(repoId).then(function () {
console.log(this.title);
this.readBranch("master").then(function () {
this.createNode({
'_type': 'custom:genericContent',
'name': 'generic1',
'description': 'this is a node named generic1',
'pageId': ['all', 'page5'],
'placementId': ['all'],
'loginState': ['all'],
'geoCode': ['all'],
'content': 'Here is some test content'
});
})
});
{
"type": "object",
"properties": {
"name": {
"type": "string",
"title": "Name"
},
"description": {
"type": "string",
"title": "Description"
},
"placementId": {
"type": "array",
"items": {
"type": "string"
},
"title": "Placement ID"
},
"pageId": {
"type": "array",
"items": {
"type": "string"
},
"title": "Page ID"
},
"geoCode": {
"type": "array",
"items": {
"type": "string"
},
"title": "Geo Code"
},
"loginState": {
"type": "array",
"items": {
"type": "string"
},
"title": "Login State"
},
"content": {
"type": "string",
"title": "Content"
}
},
"title": "Generic Content",
"description": "Just a generic content type",
"_parent": "n:node"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment