Example #1
0
	it('should be able to use named fields', function (next) {
		var Model = Arrow.Model.extend('post', {
				fields: {
					MyTitle: {name: 'title', type: String},
					MyContent: {name: 'content', type: String}
				},
				connector: 'appc.mysql'
			}),
			title = 'Test',
			content = 'Hello world',
			object = {
				MyTitle: title,
				MyContent: content
			};
		Model.create(object, function (err, instance) {
			should(err).be.not.ok;
			should(instance).be.an.Object;
			should(instance.getPrimaryKey()).be.a.Number;
			should(instance.MyTitle).equal(title);
			should(instance.MyContent).equal(content);
			Model.query({
				where: {
					MyTitle: 'Test'
				}
			}, function (err, coll) {
				should(err).be.not.ok;
				should(coll.length).be.greaterThan(0);
				instance.delete(next);
			});
		});
	});
Example #2
0
	it('should be able to ignore fields absent from schema', function (next) {
		var Model = Arrow.Model.extend('post', {
				fields: {
					MyTitle: {name: 'title', type: String},
					MyContent: {name: 'content', type: String},
					MyCustomField: {type: String}
				},
				connector: 'appc.mysql'
			}),
			title = 'Test',
			content = 'Hello world',
			object = {
				MyTitle: title,
				MyContent: content,
				MyCustomField: 'should be ignored'
			};
		Model.create(object, function (err, instance) {
			should(err).be.not.ok;
			should(instance).be.an.Object;
			should(instance.getPrimaryKey()).be.a.Number;
			should(instance.MyTitle).equal(title);
			should(instance.MyContent).equal(content);
			instance.delete(next);
		});
	});
Example #3
0
	it('API-774: should not try to update timestamp columns', function (next) {
		var model = Arrow.Model.extend(testTableName + '2', {
			fields: {amount: {type: Number}},
			connector: 'appc.mssql'
		});
		model.create({amount: 12}, function (err, instance) {
			should(err).be.not.ok;
			should(instance).be.ok;
			next();
		});

	});
	before(function (done) {
		FruitModel = Model.extend('fruit', {
			fields: {
				name: { type: String },
				color: { type: String }
			},
			connector: 'appc.arrowdb'
		});

		should(FruitModel.getConnector()).equal(this.connector);

		this.server.addModel(FruitModel);

		done();
	});
Example #5
0
	before(function(next) {
		// define your model
		Model = Arrow.Model.extend('post', {
			fields: {
				title: { type: String },
				content: { type: String }
			},
			connector: 'appc.mysql'
		});

		should(Model).be.an.object;

		Model.deleteAll(function() {
			next();
		});
	});
 before(function () {
   TestModel = Model.extend('testBase', {
     fields: {
       fname: {
         type: String, required: false
       },
       lname: {
         type: String, required: false
       },
       age: {
         type: Number, required: false
       }
     },
     connector: 'appc.arrowdb'
   });
 });
		it('should return 404 on invalid id', function(done){
			if (!FruitModel) {
				FruitModel = Model.extend('fruit', {
					fields: {
						name: { type: String },
						color: { type: String }
					},
					connector: 'appc.arrowdb'
				});

				should(FruitModel.getConnector()).equal(this.connector);

				this.server.addModel(FruitModel);
			}

			FruitModel.find('12345', function(err,resp){
				should(err).not.be.ok;
				should(resp).not.be.ok;
				done();
			});
		});
Example #8
0
	it('API-325: should be able to query with unsel', function (callback) {

		var Model = Arrow.Model.extend('post', {
			fields: {
				myTitle: {name: 'title', type: String},
				myContent: {name: 'content', type: String}
			},
			connector: 'appc.mysql'
		});
		var title = 'Test',
			content = 'Hello world',
			object = {
				myTitle: title,
				myContent: content
			};

		Model.create(object, function (err, instance) {
			should(err).be.not.ok;
			should(instance).be.an.object;

			var options = {
				where: {myContent: {$like: 'Hello%'}, myTitle: undefined},
				unsel: {myTitle: 1},
				order: {myTitle: -1, myContent: 1},
				limit: 3,
				skip: 0
			};
			Model.query(options, function (err, coll) {
				should(err).be.not.ok;

				async.eachSeries(coll, function (obj, next) {
					should(obj.getPrimaryKey()).be.a.Number;
					should(obj.myTitle).be.not.ok;
					should(obj.myContent).be.a.String;
					obj.remove(next);
				}, callback);
			});
		});

	});
var Arrow = require('arrow');

var Book = Arrow.Model.extend('book',{
	fields: {
		'title': {type:String},
		'author': {type:String}
	},
	connector: 'appc.mongo'
});

module.exports = Book;
var Arrow = require('arrow')

exports.model = Arrow.Model.extend('TEST_Post', {
  fields: {
    title: { type: String },
    content: { type: String }
  },
  connector: 'appc.mssql'
})
Example #11
0
module.exports = Arrow.Model.extend("appc.arrowdb/user", {
	/**
	 * Remove _syncModelsCanUpdateThis property or set it to false if you want to prevent syncModels.js from changing this file.
	 */
	generated: true,
	_syncModelsCanUpdateThis: false,
	/*
	 Fields for this model.
	 */
	fields: {
		"email": {
			// "originalType": "String",
			"type": String,
			"description": "User's email address.\n\nFor security, this field is not shown unless you have admin access.\n"
		},
		"username": {
			// "originalType": "String",
			"type": String,
			"description": "User's login name."
		},
		"first_name": {
			// "originalType": "String",
			"type": String,
			"description": "User's first name."
		},
		"last_name": {
			// "originalType": "String",
			"type": String,
			"description": "User's last name"
		},
		"role": {
			// "originalType": "String",
			"type": String,
			"description": "User's role."
		},
		"admin": {
			// "originalType": "Boolean",
			"type": Boolean,
			"description": "Set to true if the user is an application admin."
		},
		"external_accounts": {
			// "originalType": "Array",
			"type": Array,
			"description": "List of external accounts associated with this user. Each account is represented\nby a Hash with the following properties:\n\n*   `external_id: String`. External account ID.\n*   `external_type: String`. Account type, for example, \"facebook\".\n*   `token: String`. External account login token.\n"
		},
		"photo": {
			// "originalType": "Photos",
			"type": Array,
			"description": "Primary photo for this user."
		},
		"created_at": {
			// "originalType": "Date",
			"type": Date,
			"description": "Creation date for this user object."
		},
		"updated_at": {
			// "originalType": "Date",
			"type": Date,
			"description": "Last update time for this user object."
		},
		"friend_counts": {
			// "originalType": "Hash",
			"type": Object,
			"description": "Dictionary describing the number of friends the user has.  Possible keys returned are:\n\n  * `requests`: number of pending friend requests.\n  * `friends`: number of friends if two-way friendship is enabled.\n  * `following`: number of friends being followed by the user if one-way friendship is enabled.\n  * `follows`: number of friends following the user if one-way friendship is enabled.\n"
		},
		"custom_fields": {
			// "originalType": "",
			"type": Object,
			"description": "User defined fields."
		},
		"user_id": {
			// "originalType": "",
			"type": String,
			"description": "Specifies the owner of object."
		},
		//NOTE: added manually
		password: { type: String, hidden: true },
		password_confirmation: { type: String, hidden: true, copy_field:'password' }
	},
	/*
	 Methods for this model.
	 */
	methodMeta: {
		"query": {
			"summary": "Custom Query of Users",
			"description": "Custom query of Users objects with sorting and paginating. You can query on sort\nbased on the data in any of the standard User fields. You can also query and\nsort data based on the values of any custom fields, if the values are simple JSON\nvalues.\n\nFor security reasons, when querying for Users the email field is not returned\nin each Users object unless you have [admin access](#!/guide/admin_access).\n\nCurrently you **cannot** sort or query based on data stored inside array or hash\nobjects in custom fields.\n\nIn ACS 1.1.5 and later, you can paginate query results using `skip` and `limit` parameters, or by including\na `where` clause to limit the results to objects whose IDs fall within a specified range.\nFor details, see [Query Pagination](#!/guide/search_query-section-query-pagination).\n\nFor details about using the query parameters,\nsee the [Search and Query guide](#!/guide/search_query).\n",
			"authRequired": false,
			"instance": true,
			"adminRequired": false,
			"parameters": [
				{
					"name": "page",
					"description": "\nStarting in ACS 1.1.5, page and per_page are no longer supported in query operations. \nApplications should instead use skip and limit \nquery parameters.\n",
					"type": "Number"
				},
				{
					"name": "per_page",
					"description": "\nStarting in ACS 1.1.5, page and per_page are no longer supported in query operations. \nApplications should instead use skip and limit \nquery parameters.\n",
					"type": "Number"
				},
				{
					"name": "limit",
					"description": "The number of records to fetch. The value must be greater than 0, and no greater than \n1000, or an HTTP 400 (Bad Request) error will be returned. Default value of `limit` is 10.\n",
					"type": "Number"
				},
				{
					"name": "skip",
					"description": "The number of records to skip. The value must be greater than or equal to 0, and no greater \nthan 4999, or an HTTP 400 error will be returned. To skip 5000 records or more \nyou need to perform a range-based query. See \nQuery Pagination for more information.\n",
					"type": "Number"
				},
				{
					"name": "where",
					"description": "Constraint values for fields. `where` should be encoded JSON.\n\nIf `where` is not specified, `query` returns all objects.\n",
					"type": "Hash"
				},
				{
					"name": "order",
					"description": "Sort results by one or more fields.\n",
					"type": "String"
				},
				{
					"name": "sel",
					"description": "Selects the object fields to display. Do not use this parameter with `unsel`.\n",
					"type": "Hash"
				},
				{
					"name": "show_user_like",
					"description": "If set to **true**, each User object in the response includes `\"current_user_liked: true\"`\n if the current user has liked the object. If the user has not liked the object, the \n`current_user_liked` field is not included in the response.\n",
					"type": "Boolean"
				},
				{
					"name": "unsel",
					"description": "Selects the object fields NOT to display. Do not use this parameter with `sel`.\n",
					"type": "Hash"
				},
				{
					"name": "response_json_depth",
					"description": "Nested object depth level counts in response json.\nIn order to reduce server API calls from an application, the response json may\ninclude not just the objects that are being queried/searched, but also with\nsome important data related to the returning objects such as object's owner or\nreferencing objects.\n\nDefault is 1, valid range is 1 to 8.\n",
					"type": "Number"
				},
				{
					"name": "pretty_json",
					"description": "Determines if the JSON response is formatted for readability (`true`), or displayed on a\nsingle line (`false`). Default is `false`.\n",
					"type": "Boolean"
				}
			]
		},
		"update": {
			"summary": "",
			"description": "Any of the same parameters as create can be\nused to update the current user. If `password` is updated then\n`password_confirmation` must be sent as well.\n",
			"authRequired": true,
			"instance": true,
			"adminRequired": false,
			"response": {
				"singleElement": true
			},
			"parameters": [
				{
					"name": "email",
					"description": "Email address.",
					"type": "String"
				},
				{
					"name": "username",
					"description": "User name.",
					"type": "String"
				},
				{
					"name": "password",
					"description": "Password.",
					"type": "String"
				},
				{
					"name": "password_confirmation",
					"description": "Password.",
					"type": "String"
				},
				{
					"name": "first_name",
					"description": "First name.",
					"type": "String"
				},
				{
					"name": "last_name",
					"description": "First name.",
					"type": "String"
				},
				{
					"name": "photo",
					"description": "New photo to assign as the user's primary photo.\n\nWhen you use `photo` parameter to attach a new photo, you can use it with\n[custom resize and sync options](/docs/photosizes)\n\nTo remove primary photo, simply set \"photo=\" or \"photo_id=\". If the original\nphoto was created by using `photo` parameter, the photo will be deleted.\n",
					"type": "Photos"
				},
				{
					"name": "photo_id",
					"description": "ID of an existing photo to use as the user's primary photo.\n\nTo remove primary photo, simply set \"photo=\" or \"photo_id=\". If the original\nphoto was created by using `photo` parameter, the photo will be deleted.\n",
					"type": "String"
				},
				{
					"name": "tags",
					"description": "Comma separated tags, overwrites the existing tags. For example, \"hiking,swimming\".\n",
					"type": "String"
				},
				{
					"name": "custom_fields",
					"description": "User-defined data. See [Custom Data Fields](/docs/customfields).\n",
					"type": "String"
				},
				{
					"name": "acl_name",
					"description": "Name of an ACLs to associate with this object.\n\nAn ACL can be specified using `acl_name` or `acl_id`. The two parameters are\nmutually exclusive.\n",
					"type": "String"
				},
				{
					"name": "acl_id",
					"description": "ID of an ACLs to associate with this object.\n\nAn ACL can be specified using `acl_name` or `acl_id`. The two parameters are\nmutually exclusive.\n",
					"type": "String"
				},
				{
					"name": "pretty_json",
					"description": "Determines if the JSON response is formatted for readability (`true`), or displayed on a\nsingle line (`false`). Default is `false`.\n",
					"type": "Boolean"
				}
			]
		},
		"login": {
			"summary": "Login User",
			"description": "Log a user in using their ACS credentials.\n\nTo log a user in using an external account, see {@link\nSocialIntegrations#external_account_login External Account Login}.\n\nTo log a user out, see logout.\n\nUser login sessions expire after they have been unused for three months.\nIf the application saves and uses a persistent reference to the user login session, and the\nuser session expires, any ACS call that requires a user login will return a 404 error.\nYour application needs to handle an invalid user session error, such as prompting the user\nto log in.\n",
			"authRequired": false,
			"instance": true,
			"adminRequired": false,
			"response": {
				"singleElement": true
			},
			"parameters": [
				{
					"name": "login",
					"description": "Email address or username of the user to login.",
					"type": "String"
				},
				{
					"name": "password",
					"description": "User's password.",
					"type": "String"
				},
				{
					"name": "pretty_json",
					"description": "Determines if the JSON response is formatted for readability (`true`), or displayed on a\nsingle line (`false`). Default is `false`.\n",
					"type": "Boolean"
				}
			]
		},
		"search": {
			"summary": "Search Users",
			"description": "Returns the list of users that have been added to the app, sorted by search\nrelevancy.\n\nOptionally, `q` can be given to perform full text search on user's first name,\nlast name, email address, username and tags. For security reasons, when searching for Users\nthe email field is not returned in each Users object unless you have \n[admin access](#!/guide/admin_access).\n\nFor advanced custom search, see query.\n",
			"authRequired": false,
			"instance": true,
			"adminRequired": false,
			"parameters": [
				{
					"name": "page",
					"description": "Request page number, default is 1.",
					"type": "Number"
				},
				{
					"name": "per_page",
					"description": "Number of results per page, default is 10.",
					"type": "Number"
				},
				{
					"name": "q",
					"description": "Space-separated list of keywords, used to perform full text search on first name, last name, email address,\nusername and tags fields.\n",
					"type": "String"
				},
				{
					"name": "response_json_depth",
					"description": "Nested object depth level counts in response json.\nIn order to reduce server API calls from an application, the response json may\ninclude not just the objects that are being queried/searched, but also with\nsome important data related to the returning objects such as object's owner or\nreferencing objects.\n\nDefault is 1, valid range is 1 to 8.\n",
					"type": "Number"
				},
				{
					"name": "pretty_json",
					"description": "Determines if the JSON response is formatted for readability (`true`), or displayed on a\nsingle line (`false`). Default is `false`.\n",
					"type": "Boolean"
				}
			]
		},
		"logout": {
			"summary": "Logout User",
			"description": "Log out a user.",
			"authRequired": true,
			"instance": true,
			"adminRequired": false,
			"response": {
				"singleElement": true
			},
			"parameters": [
				{
					"name": "device_token",
					"description": "If specified, all push subscriptions associated with this device token are\ncanceled. See the \"Push Notifications\" section in the\n[Android SDK guide](#!/guide/sdks/android) for more information.\n",
					"type": "String"
				},
				{
					"name": "pretty_json",
					"description": "Determines if the JSON response is formatted for readability (`true`), or displayed on a\nsingle line (`false`). Default is `false`.\n",
					"type": "Boolean"
				}
			]
		},
		"requestResetPassword": {
			"summary": "Send a reset password email to User",
			"description": "Sends an email to a user containing a link to recover a lost password. You can use the default\nemail template provided by ACS, or specify a [custom email template](http://docs.appcelerator.com/platform/latest/#!/guide/Managing_Email_Templates-section-37548619_ManagingEmailTemplates-Creatinganemailtemplate) \nthat you have created. When using a custom email template, the email must contain a properly\nformatted URL, as explained in the `template` method parameter documentation below.\n\nYou must also have configured your application's [email settings](http://docs.appcelerator.com/platform/latest/#!/guide/Configuring_Cloud_Services-section-39683049_ConfiguringCloudServices-Email) \nin Appcelerator Dashboard or [community web console](http://my.appcelerator.com/apps).\n",
			"authRequired": false,
			"instance": true,
			"adminRequired": false,
			"response": {
				"singleElement": true
			},
			"parameters": [
				{
					"name": "email",
					"description": "Email address. Must match the user's registered email address.",
					"type": "String",
					"required": true
				},
				{
					"name": "subject",
					"description": "The default subject of the password reset email is \"Password reset request for\n{{your app name}}\". If you wish to have your custom email subject, you can\nprovide it by setting the subject parameter\n",
					"type": "String"
				},
				{
					"name": "template",
					"description": "If you wish to use your custom email body. You can create a email template and\npass the template name. The email must contain a properly formatted link to the password\nreset URL on appcelerator.com, or a link on your own site, as follows:\n\n\n**For Appcelerator Platform subscribers (enterprise users)**, to link directly to the password page on appcelerator.com, your email template must contain a link to the following\nURL:\n\n    https://dashboard.appcelerator.com/#/users/confirmation/{{key}}/{{confirmation_token}}\n\n**Community users** must use the following URL:\n\n    https://cloud.appcelerator.com/users/reset_password?key={{key}}&reset_password_token={{reset_password_token}}\n\nIf you prefer the user to reset their password on your own website, rather than on appcelerator.com,\nyou must provide a URL with the following format:\n\n    https://[your_url.com]/[your_method]?reset_password_token={{reset_password_token}}\n\nThis page must cache the value of the `reset_password_token` parameter and present a form \nthat allows the user to enter a new password and password confirmation.\nWhen the user submits the form, the app server must make the following call to Appcelerator Cloud Services API to reset the\npassword, passing the original password reset token, the user's new password, and the password confirmation:\n\n    GET https://api.cloud.appcelerator.com/v1/users/reset_password.json?key=&reset_password_token={{reset_password_token}}&password={{password}} &password_confirmation={{password_confirmation}}\n",
					"type": "String"
				},
				{
					"name": "pretty_json",
					"description": "Determines if the JSON response is formatted for readability (`true`), or displayed on a\nsingle line (`false`). Default is `false`.\n",
					"type": "Boolean"
				}
			]
		},
		"delete": {
			"summary": "Delete User",
			"description": "A user must already be logged in to their account to delete it. Any Friends-related\ndata and push notification subscriptions associated with the user are also deleted.\n\nThe user's associated primary photo is not deleted.\n",
			"authRequired": true,
			"instance": true,
			"adminRequired": false,
			"response": {
				"singleElement": true
			},
			"parameters": [
				{
					"name": "pretty_json",
					"description": "Determines if the JSON response is formatted for readability (`true`), or displayed on a\nsingle line (`false`). Default is `false`.\n",
					"type": "Boolean"
				}
			]
		},
		"showMe": {
			"summary": "Show Current User Profile",
			"description": "Shows both public and private user information about the user who is\ncurrently logged in.\n",
			"authRequired": true,
			"instance": true,
			"adminRequired": false,
			"response": {
				"singleElement": true
			},
			"parameters": [
				{
					"name": "response_json_depth",
					"description": "Nested object depth level counts in response json.\nIn order to reduce server API calls from an application, the response json may\ninclude not just the objects that are being queried/searched, but also with\nsome important data related to the returning objects such as object's owner or\nreferencing objects.\n\nDefault is 1, valid range is 1 to 8.\n",
					"type": "Number"
				},
				{
					"name": "pretty_json",
					"description": "Determines if the JSON response is formatted for readability (`true`), or displayed on a\nsingle line (`false`). Default is `false`.\n",
					"type": "Boolean"
				}
			]
		},
		"resendConfirmation": {
			"summary": "Re-send user email verification.",
			"description": "If you enabled new user account email verification in your App settings, all\nnew users will receive an email containing instructions to activate their\naccount. You can use this API to re-send user verification email.\n",
			"authRequired": false,
			"instance": true,
			"adminRequired": false,
			"response": {
				"singleElement": true
			},
			"parameters": [
				{
					"name": "email",
					"description": "Email must match user's registered email.",
					"type": "String",
					"required": true
				},
				{
					"name": "confirmation_subject",
					"description": "The default subject of the email verification is \"Email Verification\nInstructions for {{your app name}}\". If you wish to have your custom email\nsubject, you can provide it by setting the `confirmation_subject` parameter.\n",
					"type": "String"
				},
				{
					"name": "confirmation_template",
					"description": "If you wish to use your custom email body. You can create a email template and\npass the template name. Your email template must contain the following URL to\nallow users to be redirected to Appcelerator Cloud Services email verification page:\n\n    https://cloud.appcelerator.com/users/confirmation?key={{key}}&confirmation_token={{confirmation_token}}\n\nIf you have your own website that talks to Appcelerator Cloud Services backend\nand wish to use custom URL, you must provide a URL with the following format:\n\n    https://[your_url.com]/[your_method]?key={{key}}&confirmation_token={{confirmation_token}}\n\nWhen a user visits the above URL, you make a call to Appcelerator Cloud\nServices to confirm the user internally from your web server:\n\n    GET https://api.cloud.appcelerator.com/v1/users/confirm_user.json?confirmation_token={{confirmation_token}}&key=\n",
					"type": "String"
				},
				{
					"name": "pretty_json",
					"description": "Determines if the JSON response is formatted for readability (`true`), or displayed on a\nsingle line (`false`). Default is `false`.\n",
					"type": "Boolean"
				}
			]
		},
		"show": {
			"summary": "Show User Profile",
			"description": "Shows public user information. For private information about the currently\nlogged in user, see Show Logged In User Info.\n",
			"authRequired": false,
			"instance": true,
			"adminRequired": false,
			"response": {
				"singleElement": true
			},
			"parameters": [
				{
					"name": "user_id",
					"description": "User ID of the user to show. Either `user_id` or `user_ids` must be specified.\n",
					"type": "String"
				},
				{
					"name": "user_ids",
					"description": "Comma-separated list of user IDs to show. Either `user_id` or `user_ids` must be specified.\n",
					"type": "String"
				},
				{
					"name": "response_json_depth",
					"description": "Nested object depth level counts in response json.\n\nIn order to reduce server API calls from an application, the response json may\ninclude not just the objects that are being queried/searched, but also with\nsome important data related to the returning objects such as object's owner or\nreferencing objects.\n\nDefault is 1, valid range is 1 to 8.\n",
					"type": "Number"
				},
				{
					"name": "show_user_like",
					"description": "If set to **true** the User object in the response will include `\"current_user_liked: true\"`\nif the current user has liked the object. If the user has not liked the object, the \n`current_user_liked` field is not included in the response.\n",
					"type": "Boolean"
				},
				{
					"name": "pretty_json",
					"description": "Determines if the JSON response is formatted for readability (`true`), or displayed on a\nsingle line (`false`). Default is `false`.\n",
					"type": "Boolean"
				}
			]
		},
		"batchDelete": {
			"summary": "Deletes multiple Users objects.",
			"description": "Deletes Users objects that match the query constraints provided in the `where` parameter.\nIf no `where` parameter is provided, all Users objects are deleted. \nNote that an HTTP 200 code (success)\nis returned if the call completed successfully but the query matched no objects.\n\nFor performance reasons, the number of objects that can be deleted in a single batch delete \noperation is limited to 100,000.\n\nThe matched objects are deleted asynchronously in a separate process.      \n\nThe primary photos associated with the matched objects are \nnot deleted. \n\nYou must be an application admin to run this command.\n",
			"authRequired": true,
			"instance": true,
			"adminRequired": true,
			"response": {
				"singleElement": true
			},
			"parameters": [
				{
					"name": "where",
					"description": "Encoded JSON object that specifies constraint values for Users objects to delete.\nIf not specified, all Users objects are deleted.\n",
					"type": "Hash"
				}
			]
		},
		"create": {
			"summary": "Creates a user.",
			"description": "Creates a new user.\n\nWhen creating a user, you must specify either:\n\n*   username\n*   email address, first name, and last name\n\nA user can have both an email address and username specified. However, if username\nis omitted, email address, first name and last name are required.\n\nFor regular users (non-admin users), after successully executing this command, you will be logged\nin as the new user and the session ID will be associated with the newly created user.  For\nexample, when user A creates user B, user A is now logged in as user B and user A's session\nID belongs to user B.\n\nFor admin users, you will still be logged in as the admin user.\n",
			"authRequired": false,
			"instance": true,
			"adminRequired": false,
			"response": {
				"singleElement": true
			},
			"parameters": [
				{
					"name": "email",
					"description": "User's email address. Required if `username` is not specified.",
					"type": "String"
				},
				{
					"name": "username",
					"description": "User's login name. Required if `email` is not specified.\n\nIf `username` is not specified, `email`, `first_name`, and `last_name` must be included.\n",
					"type": "String"
				},
				{
					"name": "password",
					"description": "User's password.",
					"type": "String",
					"required": true
				},
				{
					"name": "password_confirmation",
					"description": "Copy of user's password for confirmation.",
					"type": "String",
					"required": true
				},
				{
					"name": "first_name",
					"description": "User's first name. Required when `username` is not provided.",
					"type": "String"
				},
				{
					"name": "last_name",
					"description": "User's last name. Required when `username` is not provided.",
					"type": "String"
				},
				{
					"name": "photo",
					"description": "New photo to attach as the primary photo for the user.\n\nWhen you use the `photo` parameter to attach a new photo, you can use the\n[custom resize and sync options](#!/guide/photosizes).\n",
					"type": "Photos"
				},
				{
					"name": "photo_id",
					"description": "ID of an existing photo to attach as the primary photo for the user.\n",
					"type": "String"
				},
				{
					"name": "tags",
					"description": "Comma separated list of tags for this user.\n",
					"type": "String"
				},
				{
					"name": "custom_fields",
					"description": "User defined fields. See [Custom Data Fields](#!/guide/customfields).",
					"type": [
						"String",
						"Hash"
					]
				},
				{
					"name": "acl_name",
					"description": "Name of an ACLs to associate with this object.\n\nAn ACL can be specified using `acl_name` or `acl_id`. The two parameters are\nmutually exclusive.\n",
					"type": "String"
				},
				{
					"name": "acl_id",
					"description": "ID of an ACLs to associate with this object.\n\nAn ACL can be specified using `acl_name` or `acl_id`. The two parameters are\nmutually exclusive.\n",
					"type": "String"
				},
				{
					"name": "role",
					"description": "String representation of user role, for example, \"teacher\".",
					"type": "String"
				},
				{
					"name": "template",
					"description": "Send a congratulation email to notify that the user has been created successfully.\n\nYou need to create an email template and pass the template name.\n",
					"type": "String"
				},
				{
					"name": "confirmation_template",
					"description": "If \"New User Email Verification\" is enabled for the application, ACS sends a confirmation email to\nthe user.\n\nIf you don't pass the `confirmation_template` parameter, then ACS sends a default\nconfirmation email.\n\nIf you wish to use your custom email body, you can create a email template and pass\nthe template name. Your email template must contain the following URL to allow users\nto be redirected to Appcelerator Cloud Services email verification page:\n\n     https://cloud.appcelerator.com/users/confirmation?key={{key}}&confirmation_token={{confirmation_token}}\n\nIf you have your own website that talks to Appcelerator Cloud Services backend and\nwish to use custom URL, you must provide a URL with the following format:\n\n     https:///?key={{key}}&confirmation_token={{confirmation_token}}\n\nWhen a user visits the above URL, you call the ACS `users/confirm_user.json` method to \nconfirm the user internally from your web server:\n\n     GET https://api.cloud.appcelerator.com/v1/users/confirm_user.json?confirmation_token={{confirmation_token}}&key=\n\n**Enterprise users** must append the query parameter `&ct=enterprise` to the end of the URL:\n\n     GET https://api.cloud.appcelerator.com/v1/users/confirm_user.json?confirmation_token={{confirmation_token}}&key=&ct=enterprise\n",
					"type": "String"
				},
				{
					"name": "pretty_json",
					"description": "Determines if the JSON response is formatted for readability (`true`), or displayed on a\nsingle line (`false`). Default is `false`.\n",
					"type": "Boolean"
				}
			]
		},
		"remove": {
			"canonical": "delete"
		}
		
	},

	_prepareParams: function prepareParams(method, instance, params, defaultValue) {
		params || (params = {});
		switch (method) {
			//NOTE: added manually
			case 'login': 
				return  {
					login: instance.username,
					password: params.password
				};
			case 'update':
				defaultValue.user_id = instance.getPrimaryKey();
				return defaultValue;
			case 'delete':
				return {
					user_id: instance.getPrimaryKey()
				};
		}
		return defaultValue;
	},

	actions: ["read","update","delete","create"]
});
Example #12
0
var Arrow = require('arrow');

var User = Arrow.Model.extend('testuser',{
	fields: {
		first_name: {type:String},
		last_name: {type:String},
		email: {type:String}
	},
	connector: 'appc.arrowdb'
});

module.exports = User;
Example #13
0
	before(function (callback) {
		// define your model
		Model = Arrow.Model.extend(testTableName, {
			fields: {
				title: {type: String},
				content: {type: String}
			},
			connector: 'appc.mssql'
		});

		should(Model).be.an.Object;

		// Set up our testing table.
		var connection = connector.connection;
		async.series([
			function (next) {
				var request = new sql.Request(connection);
				request.query('DROP TABLE ' + testTableName, function (err) {
					if (!err || String(err).indexOf('because it does not exist') >= 0) {
						next();
					}
					else {
						callback(err);
					}
				});
			},
			function (next) {
				var request = new sql.Request(connection);
				request.query('DROP TABLE ' + testTableName + '2', function (err) {
					if (!err || String(err).indexOf('because it does not exist') >= 0) {
						next();
					}
					else {
						callback(err);
					}
				});
			},
			function (next) {
				var request = new sql.Request(connection);
				request.query('DROP TABLE ' + testTableName + '3', function (err) {
					if (!err || String(err).indexOf('because it does not exist') >= 0) {
						next();
					}
					else {
						callback(err);
					}
				});
			},
			function (next) {
				var request = new sql.Request(connection);
				request.query('CREATE TABLE ' + testTableName + ' (id INT IDENTITY, title VARCHAR(255), content VARCHAR(255))',
					function (err) {
						if (!err || String(err).indexOf('There is already an object named') >= 0) {
							next();
						}
						else {
							callback(err);
						}
					});
			},
			function (next) {
				var request = new sql.Request(connection);
				request.query('CREATE UNIQUE CLUSTERED INDEX Idx_' + testTableName + ' ON ' + testTableName + '(id)', function (err) {
					if (!err || String(err).indexOf('already exists on table') >= 0) {
						next();
					}
					else {
						callback(err);
					}
				});
			},
			function (next) {
				var request = new sql.Request(connection);
				request.query('ALTER TABLE ' + testTableName + ' ADD CONSTRAINT PK_' + testTableName + ' PRIMARY KEY(id)', function (err) {
					if (!err || String(err).indexOf('already exists on table') >= 0) {
						next();
					}
					else {
						callback(err);
					}
				});
			},
			function (next) {
				var request = new sql.Request(connection);
				request.query('CREATE TABLE ' + testTableName + '2 (id INT IDENTITY, amount INT, timestamp)',
					function (err) {
						if (!err || String(err).indexOf('There is already an object named') >= 0) {
							next();
						}
						else {
							callback(err);
						}
					});
			},
			function (next) {
				var request = new sql.Request(connection);
				request.query('CREATE UNIQUE CLUSTERED INDEX Idx_' + testTableName + '2 ON ' + testTableName + '2(id)', function (err) {
					if (!err || String(err).indexOf('already exists on table') >= 0) {
						next();
					}
					else {
						callback(err);
					}
				});
			},
			function (next) {
				var request = new sql.Request(connection);
				request.query('ALTER TABLE ' + testTableName + '2 ADD CONSTRAINT PK_' + testTableName + '2 PRIMARY KEY(id)', function (err) {
					if (!err || String(err).indexOf('already exists on table') >= 0) {
						next();
					}
					else {
						callback(err);
					}
				});
			},
			function (next) {
				var request = new sql.Request(connection);
				request.query('CREATE TABLE ' + testTableName + '3 (rid INT IDENTITY, amount INT, timestamp)',
					function (err) {
						if (!err || String(err).indexOf('There is already an object named') >= 0) {
							next();
						}
						else {
							callback(err);
						}
					});
			},
			function (next) {
				var request = new sql.Request(connection);
				request.query('CREATE UNIQUE CLUSTERED INDEX Idx_' + testTableName + '3 ON ' + testTableName + '3(rid)', function (err) {
					if (!err || String(err).indexOf('already exists on table') >= 0) {
						next();
					}
					else {
						callback(err);
					}
				});
			},
			function (next) {
				var request = new sql.Request(connection);
				request.query('ALTER TABLE ' + testTableName + '3 ADD CONSTRAINT PK_' + testTableName + '3 PRIMARY KEY(rid)', function (err) {
					if (!err || String(err).indexOf('already exists on table') >= 0) {
						next();
					}
					else {
						callback(err);
					}
				});
			}
		], callback);

	});
Example #14
0
// jscs:disable jsDoc
var Arrow = require('arrow');

exports.model = Arrow.Model.extend('post', {
	fields: {
		title: {type: String},
		content: {type: String}
	}
});
Example #15
0
module.exports = Arrow.Model.extend("appc.arrowdb/photo", {
	/**
	 * Remove _syncModelsCanUpdateThis property or set it to false if you want to prevent syncModels.js from changing this file.
	 */
	_syncModelsCanUpdateThis: true,

	/**
	 * indicate that the model was generated
	 */
	generated: true,

	/**
	 * if this model is visible
	 */
	visible: true,

	/*
	 Fields for this model.
	 */
	fields: {
		"filename": {
			// "originalType": "String",
			"type": String,
			"description": "Filename of the original photo."
		},
		"photo": {
			"type": Object,
			"description": "The attached binary file for creation."
		},
		"title": {
			// "originalType": "String",
			"type": String,
			"description": "Photo title, if specified."
		},
		"size": {
			// "originalType": "Number",
			"type": Number,
			"description": "Original image size in bytes."
		},
		"collections": {
			// "originalType": "Array",
			"type": Array,
			"description": "Single-element array containing the collection this photo is a part of, if any."
		},
		"md5": {
			// "originalType": "String",
			"type": String,
			"description": "MD5 hash of the original image data."
		},
		"processed": {
			// "originalType": "Boolean",
			"type": Boolean,
			"description": "True if this photo has been processed and is available for download."
		},
		"content_type": {
			// "originalType": "String",
			"type": String,
			"description": "MIME content-type for this photo."
		},
		"urls": {
			// "originalType": "Hash",
			"type": Object,
			"description": "A hash containing image URLs for the photo at different sizes. The keys in the hash correspond to  the photo sizes described in [Photo Uploading & Resizing](#!/guide/photosizes):  * square_75 * thumb_100 * small_240 * medium_500 * medium_640 * large_1024 * original  The URLs are only available after the photo has been processed (`processed` is `true`). "
		},
		"created_at": {
			// "originalType": "Date",
			"type": Date,
			"description": "Creation date for this photo object."
		},
		"updated_at": {
			// "originalType": "Date",
			"type": Date,
			"description": "Last update time for this photo object."
		},
		"tags": {
			// "originalType": "Array",
			"type": Array,
			"description": "List of tags for this photo."
		},
		"custom_fields": {
			// "originalType": "Hash",
			"type": Object,
			"description": "User defined fields. See [Custom Data Fields](#!/guide/customfields)."
		},
		"acls": {
			// "originalType": "String",
			"type": String,
			"description": "Single-element array containing the ACLs associated with this photo object, if any. "
		},
		"user": {
			// "originalType": "Users",
			"type": Array,
			"description": "User object for the photo's owner. "
		},
		"user_id": {
			// "originalType": "",
			"type": String,
			"description": "Specifies the owner of object."
		},
		"reviews": {
			// "originalType": "Array",
			"type": Array,
			"description": "List of reviews for this object.  Only present if the object has been reviewed. "
		},
		"reviews_count": {
			// "originalType": "Number",
			"type": Number,
			"description": "Total number of reviews for this object.  Only present if the object has been reviewed. "
		},
		"ratings_count": {
			// "originalType": "Number",
			"type": Number,
			"description": "Total number of reviews for this object that include a rating.  Only present if the object has been reviewed. "
		},
		"ratings_average": {
			// "originalType": "Number",
			"type": Number,
			"description": "Average rating for this object. Only present if the object has been reviewed."
		},
		"ratings_summary": {
			// "originalType": "Hash",
			"type": Object,
			"description": "Breakdown of the number of reviews that specified a given rating value. For example, if your ratings range from 1-5, the ratings summary might look like this:      ratings_summary: {         \"1\" : 1,         \"2\" : 0,         \"3\" : 5,         \"4\" : 50,         \"5\" : 12     }  Only present if the object has been reviewed. "
		}
	},
	/*
	 Methods for this model.
	 */
	methodMeta: {
		"delete": {
			"summary": "Delete a Photo",
			"description": "Deletes a photo to which you have update access.  An application admin can delete any photo object. ",
			"authRequired": true,
			"instance": true,
			"adminRequired": false,
			"response": {
				"singleElement": true
			},
			"parameters": [
				{
					"name": "photo_id",
					"description": "ID of the photo to delete.",
					"type": "String",
					"required": true
				},
				{
					"name": "su_id",
					"description": "User ID to delete the Photo object on behalf of. The user must be the creator of the object.\n\nThe current login user must be an application admin to delete a Photo object on\nbehalf of another user.\n",
					"type": "String"
				},
				{
					"name": "pretty_json",
					"description": "Determines if the JSON response is formatted for readability (`true`), or displayed on a\nsingle line (`false`). Default is `false`.\n",
					"type": "Boolean"
				}
			]
		},
		"create": {
			"summary": "Create (Upload) a Photo",
			"description": "Create a photo using the given `photo` binary attachment. A `collection_name` or `collection_id` is optional. The response includes a `processed` flag which indicates if the photo has been resized and stored reliably in the Appcelerator Cloud Services storage engine. This will initially be `false`. The `md5` field gives the md5 sum of the file which can be used to verify file integrity. ",
			"authRequired": true,
			"instance": true,
			"adminRequired": false,
			"response": {
				"singleElement": true
			},
			"parameters": [
				{
					"name": "photo",
					"description": "The attached binary file.\n",
					"type": "FileUpload",
					"required": true
				},
				{
					"name": "title",
					"description": "Photo title.",
					"type": "String"
				},
				{
					"name": "collection_name",
					"description": "Name of the PhotoCollections to add this photo to.",
					"type": "String"
				},
				{
					"name": "collection_id",
					"description": "ID of the PhotoCollections to add this photo to.",
					"type": "String"
				},
				{
					"name": "tags",
					"description": "Comma separated list of tags to associate with this photo.\n",
					"type": "String"
				},
				{
					"name": "custom_fields",
					"description": "User-defined fields to add to this photo. See [Custom Data Fields](#!/guide/customfields).",
					"type": [
						"String",
						"Hash"
					]
				},
				{
					"name": "acl_name",
					"description": "Name of an ACLs to associate with this photo object.\n\nAn ACL can be specified using `acl_name` or `acl_id`. The two parameters are\nmutually exclusive.\n",
					"type": "String"
				},
				{
					"name": "acl_id",
					"description": "ID of an ACLs to associate with this photo object.\n\nAn ACL can be specified using `acl_name` or `acl_id`. The two parameters are\nmutually exclusive.\n",
					"type": "String"
				},
				{
					"name": "su_id",
					"description": "User ID to create the photo on behalf of.\n\nThe current login user must be an application admin to create a photo on\nbehalf of another user.\n",
					"type": "String"
				},
				{
					"name": "photo_sizes",
					"description": "User-defined photo sizes. See [Photo Uploading &\nSizes](#!/guide/photosizes#custom).  Sizes be specified as a JSON object, or using a separate parameter for each\nsize. To specify a photo size called \"preview\" using JSON:\n\n    photo_size : { \"preview\" : \"120x120#\" }\n\nTo pass each size as a separate parameter, do *not* use the literal parameter name `photo_sizes`,\nbut add a parameter named `photo_sizes[`_sizeName_`]` for each custom photo\nsize. The previous example in this format looks like this:\n\n    \"photo_size[preview]\" : \"120x120#\"\n",
					"type": [
						"String",
						"Hash"
					]
				},
				{
					"name": "photo_sync_sizes[]",
					"description": "Synchronous photo sizes to upload. See [Photo Uploading & Resizing](#!/guide/photosizes).\n\nThe literal name for this parameter is `photo_sync_sizes[]`. This parameter can be specified\nmultiple times, once for each photo size that must be created before the request returns.\n\nFor example:\n\n    \"photo_sync_sizes[]=preview\"\n",
					"type": "String"
				},
				{
					"name": "pretty_json",
					"description": "Determines if the JSON response is formatted for readability (`true`), or displayed on a\nsingle line (`false`). Default is `false`.\n",
					"type": "Boolean"
				}
			]
		},
		"show": {
			"summary": "Show Photo Info",
			"description": "Returns the information for the identified photo. ",
			"authRequired": false,
			"instance": true,
			"adminRequired": false,
			"response": {
				"singleElement": true
			},
			"parameters": [
				{
					"name": "photo_id",
					"description": "ID of the photo to show.",
					"type": "String",
					"required": true
				},
				{
					"name": "response_json_depth",
					"description": "Nested object depth level counts in response JSON.\n\nIn order to reduce server API calls from an application, the response JSON may\ninclude not just the objects that are being queried/searched, but also\nsome important data related to the returned objects such as object's owner or\nreferenced objects.\n\nDefault is 1, valid range is 1 to 8.\n",
					"type": "Number"
				},
				{
					"name": "show_user_like",
					"description": "If set to **true** the Photo object in the response will include `\"current_user_liked: true\"`\nif the current user has liked the object. If the user has not liked the object, the \n`current_user_liked` field is not included in the response.\n",
					"type": "Boolean"
				},
				{
					"name": "pretty_json",
					"description": "Determines if the JSON response is formatted for readability (`true`), or displayed on a\nsingle line (`false`). Default is `false`.\n",
					"type": "Boolean"
				}
			]
		},
		"query": {
			"summary": "Custom Query Photos",
			"description": "Perform custom query of photos with sorting and paginating. Currently you can not query or sort data stored inside array or hash in custom fields.  In addition to custom fields, here is a list of pre-defined fields that can be queried and sorted:  *   `user_id: String`. Photo owner's user ID. *   `title:  String`.  Photo title. *   `tags_array: String`. Photo tags. *   `ratings_average:  Number`.  Photo's average rating (see Reviews). *   `ratings_count: Number`. Photo's total number of ratings (see Reviews). *   `reviews_count: Number`. Photo's total number of reviews (see Reviews). *   `created_at: Date`. Timestamp when the photo was created. *   `updated_at: Date`. Timestamp when the photo was updated.  In ACS 1.1.5 and later, you can paginate query results using `skip` and `limit` parameters, or by including a `where` clause to limit the results to objects whose IDs fall within a specified range. For details, see [Query Pagination](#!/guide/search_query-section-query-pagination).  For details about using the query parameters, see the [Search and Query guide](#!/guide/search_query). ",
			"authRequired": false,
			"instance": true,
			"adminRequired": false,
			"parameters": [
				{
					"name": "page",
					"description": "\nStarting in ACS 1.1.5, page and per_page are no longer supported in query operations. \nApplications should instead use skip and limit \nquery parameters.\n",
					"type": "Number"
				},
				{
					"name": "per_page",
					"description": "\nStarting in ACS 1.1.5, page and per_page are no longer supported in query operations. \nApplications should instead use skip and limit \nquery parameters.\n",
					"type": "Number"
				},
				{
					"name": "limit",
					"description": "The number of records to fetch. The value must be greater than 0, and no greater than \n1000, or an HTTP 400 (Bad Request) error will be returned. Default value of `limit` is 10.\n",
					"type": "Number"
				},
				{
					"name": "skip",
					"description": "The number of records to skip. The value must be greater than or equal to 0, and no greater \nthan 4999, or an HTTP 400 error will be returned. To skip 5000 records or more \nyou need to perform a range-based query. See \nQuery Pagination for more information.\n",
					"type": "Number"
				},
				{
					"name": "where",
					"description": "Constraint values for fields. `where` should be encoded JSON.\n\nIf `where` is not specified, `query` returns all objects.\n",
					"type": "Hash"
				},
				{
					"name": "order",
					"description": "Sort results by one or more fields.\n",
					"type": "String"
				},
				{
					"name": "sel",
					"description": "Selects the object fields to display. Do not use this parameter with `unsel`.\n",
					"type": "Hash"
				},
				{
					"name": "show_user_like",
					"description": "If set to **true**, each Photo object in the response includes `\"current_user_liked: true\"`\n if the current user has liked the object. If the user has not liked the object, the \n`current_user_liked` field is not included in the response.\n",
					"type": "Boolean"
				},
				{
					"name": "unsel",
					"description": "Selects the object fields NOT to display. Do not use this parameter with `sel`.\n",
					"type": "Hash"
				},
				{
					"name": "response_json_depth",
					"description": "Nested object depth level counts in response json.\nIn order to reduce server API calls from an application, the response json may\ninclude not just the objects that are being queried/searched, but also with\nsome important data related to the returning objects such as object's owner or\nreferencing objects.\n\nDefault is 1, valid range is 1 to 8.\n",
					"type": "Number"
				},
				{
					"name": "pretty_json",
					"description": "Determines if the JSON response is formatted for readability (`true`), or displayed on a\nsingle line (`false`). Default is `false`.\n",
					"type": "Boolean"
				}
			]
		},
		"search": {
			"summary": "Seach for Photos",
			"description": "Searches for photos with sorting and paginating. ",
			"authRequired": false,
			"instance": true,
			"adminRequired": false,
			"parameters": [
				{
					"name": "page",
					"description": "Request page number, default is 1.",
					"type": "Number"
				},
				{
					"name": "per_page",
					"description": "Number of results per page, default is 10.",
					"type": "Number"
				},
				{
					"name": "response_json_depth",
					"description": "Nested object depth level counts in response JSON.\n\nIn order to reduce server API calls from an application, the response JSON may\ninclude not just the objects that are being queried/searched, but also\nsome important data related to the returned objects such as object's owner or\nreferenced objects.\n\nDefault is 1, valid range is 1 to 8.\n",
					"type": "Number"
				},
				{
					"name": "pretty_json",
					"description": "Determines if the JSON response is formatted for readability (`true`), or displayed on a\nsingle line (`false`). Default is `false`.\n",
					"type": "Boolean"
				}
			]
		},
		"update": {
			"summary": "Update a Photo",
			"description": "Updates the photo attachment, the collection that the photo belongs to, or other photo properties. When replacing the existing photo attachment with a new one, `processing` will be set to `false`. However the existig URLs will remain valid until the new photo has been processed and uploaded to the Appcelerator Cloud Services storage cloud. At this time, the old URLs will be replaced with the URLs of the newly processed photo.  An application admin can update any Photo object. ",
			"authRequired": true,
			"instance": true,
			"adminRequired": false,
			"response": {
				"singleElement": true
			},
			"parameters": [
				{
					"name": "photo_id",
					"description": "ID of the photo to update.",
					"type": "String",
					"required": true
				},
				{
					"name": "photo",
					"description": "New photo to associate with this object, attached as a binary file.\n",
					"type": "FileUpload",
					"required": true
				},
				{
					"name": "title",
					"description": "Photo title.",
					"type": "String"
				},
				{
					"name": "collection_name",
					"description": "Name of the PhotoCollections to add this photo to. Replaces the\nexisting collection, if any.\n",
					"type": "String"
				},
				{
					"name": "collection_id",
					"description": "ID of the PhotoCollections to add this photo to. Replaces the existing\ncollection, if any.\n",
					"type": "String"
				},
				{
					"name": "tags",
					"description": "Comma separated list of tags to associate with this photo. Overwrites any\nexisting tags.\n",
					"type": "String"
				},
				{
					"name": "custom_fields",
					"description": "User-defined fields to add to this photo. See [Custom Data Fields](#!/guide/customfields).",
					"type": [
						"String",
						"Hash"
					]
				},
				{
					"name": "acl_name",
					"description": "Name of an ACLs to associate with this photo object.\n\nAn ACL can be specified using `acl_name` or `acl_id`. The two parameters are\nmutually exclusive.\n\nTo delete an ACL, set `acl_name` or `acl_id` to the empty string.\n",
					"type": "String"
				},
				{
					"name": "acl_id",
					"description": "ID of an ACLs to associate with this photo object.\n\nAn ACL can be specified using `acl_name` or `acl_id`. The two parameters are\nmutually exclusive.\n",
					"type": "String"
				},
				{
					"name": "photo_sizes",
					"description": "User-defined photo sizes. See [Photo Uploading & Resizings](#!/guide/photosizes).\nSizes be specified as a JSON object, or using a separate parameter for each\nsize. To specify a photo size called \"preview\" using JSON:\n\n    photo_size : { \"preview\" : \"120x120#\" }\n\nTo pass each size as a separate parameter, do *not* use the literal parameter name `photo_sizes`,\nbut add a parameter named `photo_sizes[`_sizeName_`]` for each custom photo\nsize. The previous example in this format looks like this:\n\n    \"photo_size[preview]\" : \"120x120#\"\n",
					"type": [
						"String",
						"Hash"
					]
				},
				{
					"name": "photo_sync_sizes",
					"description": "Synchronous photo sizes to upload. See [Photo Uploading & Resizings](#!/guide/photosizes).\n\nThe literal name for this parameter is `photo_sync_sizes[]`. This parameter can be specified\nmultiple times, once for each photo size that must be created before the request returns.\n\nFor example:\n\n    \"photo_sync_sizes[]=preview\"\n",
					"type": "String"
				},
				{
					"name": "su_id",
					"description": "User ID to update the Photo object on behalf of. The user must be the creator of the object.\n\nThe current login user must be an application admin to update a Photo object on\nbehalf of another user.\n",
					"type": "String"
				},
				{
					"name": "pretty_json",
					"description": "Determines if the JSON response is formatted for readability (`true`), or displayed on a\nsingle line (`false`). Default is `false`.\n",
					"type": "Boolean"
				}
			]
		},
		"batchDelete": {
			"summary": "Deletes multiple Photos objects.",
			"description": "Deletes Photos objects that match the query constraints provided in the `where` parameter. If no `where` parameter is provided, all Photos objects are deleted.  Note that an HTTP 200 code (success) is returned if the call completed successfully but the query matched no objects.  For performance reasons, the number of objects that can be deleted in a single batch delete  operation is limited to 100,000.  The matched objects are deleted asynchronously in a separate process.                  You must be an application admin to run this command.         ",
			"authRequired": true,
			"instance": true,
			"adminRequired": true,
			"response": {
				"singleElement": true
			},
			"parameters": [
				{
					"name": "where",
					"description": "Encoded JSON object that specifies constraint values for Photos objects to delete.\nIf not specified, all Photos objects are deleted.\n",
					"type": "Hash"
				}
			]
		},
		"remove": {
			"canonical": "delete"
		}
		
	},

	_prepareParams: function prepareParams(method, instance, params, defaultValue) {
		params || (params = {});
		switch (method) {
			case 'update':
				defaultValue.photo_id = instance.getPrimaryKey();
				return defaultValue;
			case 'delete':
				return {
					photo_id: instance.getPrimaryKey()
				};
		}
		return defaultValue;
	},

	actions: ["delete","create","read","update"]
});
exports.createModelsFromSchema = function () {
	var self = this,
		models = {},
		schema = this.schema;

	for (var modelName in schema) {
		if (schema.hasOwnProperty(modelName)) {
			var methodNames = _.keys(schema[modelName]);
			if (methodNames.length === 0) {
				continue;
			}

			var fields = {},
				verbs;

			for (var i = 0; i < methodNames.length; i++) {
				verbs = _.values(schema[modelName][methodNames[i]].verbs);
				for (var j = 0; j < verbs.length; j++) {
					defineFields(fields, verbs[j]);
				}
			}

			var Model = Arrow.Model.extend(this.name + '/' + modelName, {
				generated: true,
				name: this.name + '/' + modelName,
				connector: self,
				autogen: self.config.modelAutogen,
				actions: Object.keys(schema[modelName]),
				fields: fields
			});
			Model._hasOwnFields = false;
			self.logger.trace('┏');
			self.logger.trace('┃ ' + this.name + '/' + modelName);

			for (var k = 0; k < methodNames.length; k++) {
				var name = methodNames[k],
					method = schema[modelName][name];
				verbs = _.values(method.verbs);

				for (var l = 0; l < verbs.length; l++) {
					var verb = verbs[l],
						executionContext = {
							model: Model,
							connector: self,
							methodName: name,
							method: method.func,
							verb: verb.verb,
							input: verb.input,
							output: verb.output,
							context: method.context,
							handleResponse: self.config.handleResponse,
							xmlOptions: self.config.xmlOptions
						};

					if (!Model[name] && name !== 'get') {
						reversibleBind(Model, name, self.execute, executionContext);
						reversibleBind(Model, name + 'API', self.describe, executionContext);
						self.logger.trace('┣ .' + name + '([data, ]cb);');
					} else {
						reversibleBind(Model, name + verb.suffix, self.execute, executionContext);
						reversibleBind(Model, name + verb.suffix + 'API', self.describe, executionContext);
						self.logger.trace('┣ .' + name + verb.suffix + '([data, ]cb);');
					}
				}
			}

			models[this.name + '/' + modelName] = Model;
			self.logger.trace('┗');
		}
	}

	self.models = _.defaults(self.models || {}, models);
};
Example #17
0
/**
 * NOTE: This file is simply for testing this connector and will not
 * be used or packaged with the actual connector when published.
 */
var Arrow = require('arrow'),
	server = new Arrow();

var Post = Arrow.Model.extend('post', {
	fields: {
		title: {type: String},
		content: {type: String}
	},
	connector: 'appc.mysql'
});
server.addModel(Post);

server.start(function (err) {
	if (err) { server.logger.fatal(err); }
	server.logger.info('server started on port', server.port);

	// Create some posts programmatically.
	var posts = [
		{title: 'A journey through time', content: 'take a journey'},
		{title: 'The Bible', content: 'In the beginning, God created the heavens and the earth.'}
	];
	Post.create(posts, function (err, posts) {
		if (err) { return server.logger.error(err); }
		server.logger.info('Created some posts:', [posts[0], posts[1]]);

		Post.find({title: 'The Bible'}, function (err, results) {
			server.logger.info('Found The Bible:', results && results[0]);
var Arrow = require('arrow');

exports.model = Arrow.Model.extend('testUser', {
	fields: {
		name: {type: String, required: false, validator: /[a-zA-Z]{3,}/}
	},
	connector: 'appc.mongo',
	metadata: {
		'appc.mongo': {
			collection: 'users'
		}
	}
});
Example #19
0
module.exports = Arrow.Model.extend("appc.arrowdb/keyValue", {
	/**
	 * Remove _syncModelsCanUpdateThis property or set it to false if you want to prevent syncModels.js from changing this file.
	 */
	_syncModelsCanUpdateThis: true,

	/**
	 * indicate that the model was generated
	 */
	generated: true,

	/**
	 * if this model is visible
	 */
	visible: true,

	/*
	 Fields for this model.
	 */
	fields: {
		"name": {
			// "originalType": "String",
			"type": String,
			"description": "Name (or key) for this key-value pair."
		},
		"type": {
			// "originalType": "String",
			"type": String,
			"description": "Value type: \"string\" or \"binary\".  If type is omitted, defaults to \"string\". "
		},
		"value": {
			// "originalType": "String,BinaryData",
			"type": Object,
			"description": "String or binary data. "
		},
		"custom_fields": {
			// "originalType": "",
			"type": Object,
			"description": "User defined fields."
		},
		"user_id": {
			// "originalType": "",
			"type": String,
			"description": "Specifies the owner of object."
		}
	},
	/*
	 Methods for this model.
	 */
	methodMeta: {
		"append": {
			"summary": "Append to a Key-Value",
			"description": "Add the given `value` to end of the existing one. Not allowed on key-values with binary data. ",
			"authRequired": true,
			"instance": true,
			"adminRequired": false,
			"response": {
				"singleElement": true,
				"model": "keyvalues"
			},
			"parameters": [
				{
					"name": "name",
					"description": "Name (or key) for the key-value pair.",
					"type": "String",
					"required": true
				},
				{
					"name": "value",
					"description": "Value to append to the current value.",
					"type": "String",
					"required": true
				},
				{
					"name": "access_private",
					"description": "Determines whether to update this key-value in the publically readable store\nor in the user's private store.\n\nDefault is false (publically readable).\n",
					"type": "Boolean"
				},
				{
					"name": "su_id",
					"description": "Update the key-value pair on behalf of the identified user.\n\nLogin user must be an admin to update a key-value on behalf of another user.\n",
					"type": "String"
				},
				{
					"name": "pretty_json",
					"description": "Determines if the JSON response is formatted for readability (`true`), or displayed on a\nsingle line (`false`). Default is `false`.\n",
					"type": "Boolean"
				}
			]
		},
		"delete": {
			"summary": "Delete a Key-Value",
			"description": "Deletes a key-value pair ",
			"authRequired": true,
			"instance": true,
			"adminRequired": false,
			"response": {
				"singleElement": true,
				"model": "keyvalues"
			},
			"parameters": [
				{
					"name": "name",
					"description": "Name (or key) of the key-value pair to delete.",
					"type": "String",
					"required": true
				},
				{
					"name": "access_private",
					"description": "Determines whether to delete this key-value in the publically readable store\nor in the user's private store.\n\nDefault is false (publically readable store).\n",
					"type": "Boolean"
				},
				{
					"name": "su_id",
					"description": "Delete the key-value pair on behalf of the identified user.\n\nLogin user must be an admin to delete a key-value on behalf of another user.\n",
					"type": "String"
				},
				{
					"name": "pretty_json",
					"description": "Determines if the JSON response is formatted for readability (`true`), or displayed on a\nsingle line (`false`). Default is `false`.\n",
					"type": "Boolean"
				}
			]
		},
		"query": {
			"summary": "Performs a custom query of KeyValues.",
			"description": "Performs a custom query of KeyValues. Currently you can not query or sort data stored inside  an array or hash in custom fields.  In ACS 1.1.5 and later, you can paginate query results using `skip` and `limit` parameters, or by including a `where` clause to limit the results to objects whose IDs fall within a specified range. For details, see [Query Pagination](#!/guide/search_query-section-query-pagination).          For details about using the query parameters, see the [Search and Query guide](#!/guide/search_query). ",
			"authRequired": false,
			"instance": true,
			"adminRequired": false,
			"parameters": [
				{
					"name": "page",
					"description": "\nStarting in ACS 1.1.5, page and per_page are no longer supported in query operations. \nApplications should instead use skip and limit \nquery parameters.\n",
					"type": "Number"
				},
				{
					"name": "per_page",
					"description": "\nStarting in ACS 1.1.5, page and per_page are no longer supported in query operations. \nApplications should instead use skip and limit \nquery parameters.\n",
					"type": "Number"
				},
				{
					"name": "limit",
					"description": "The number of records to fetch. The value must be greater than 0, and no greater than \n1000, or an HTTP 400 (Bad Request) error will be returned. Default value of `limit` is 10.\n",
					"type": "Number"
				},
				{
					"name": "skip",
					"description": "The number of records to skip. The value must be greater than or equal to 0, and no greater \nthan 4999, or an HTTP 400 error will be returned. To skip 5000 records or more \nyou need to perform a range-based query. See \nQuery Pagination for more information.\n",
					"type": "Number"
				},
				{
					"name": "pretty_json",
					"description": "Determines if the JSON response is formatted for readability (`true`), or displayed on a\nsingle line (`false`). Default is `false`.\n",
					"type": "Boolean"
				},
				{
					"name": "where",
					"description": "Constraint values for fields. `where` should be encoded JSON.\n\nYou can query any of the standard values for an ACL object, as well as any\ncustom fields that contain simple values, such as String, Number or Boolean\nvalues.\n\nIf `where` is not specified, `query` returns all objects.\n",
					"type": "Hash"
				},
				{
					"name": "order",
					"description": "Sort results by one or more fields.\n",
					"type": "String"
				},
				{
					"name": "sel",
					"description": "Selects the object fields to display. Do not use this parameter with `unsel`.\n",
					"type": "Hash"
				},
				{
					"name": "unsel",
					"description": "Selects the object fields NOT to display. Do not use this parameter with `sel`.\n",
					"type": "Hash"
				},
				{
					"name": "response_json_depth",
					"description": "Nested object depth level counts in response json.\nIn order to reduce server API calls from an application, the response json may\ninclude not just the objects that are being queried/searched, but also with\nsome important data related to the returning objects such as object's owner or\nreferencing objects.\n\nDefault is 1, valid range is 1 to 8.\n",
					"type": "Number"
				}
			]
		},
		"get": {
			"summary": "Get a Value",
			"description": "Gets the value of a key-value pair.  If the value is string, the KeyValue object is returned in JSON format. If the value is binary, the value is returned directly **without** a JSON wrapper and the content type is set to \"application/octct-stream\". ",
			"authRequired": false,
			"instance": true,
			"adminRequired": false,
			"response": {
				"singleElement": true,
				"model": "keyvalues"
			},
			"parameters": [
				{
					"name": "name",
					"description": "Name (or key) for the key-value pair to retrieve.",
					"type": "String",
					"required": true
				},
				{
					"name": "access_private",
					"description": "Determines whether to retrieve this key-value from the publically readable store\nor from the user's private store.\n\nDefault is false (publically readable).\n",
					"type": "Boolean"
				},
				{
					"name": "user_id",
					"description": "Retrieve a private key-value pair from the identified user's store.\n\nLogin user must be an application admin to retrieve a key-value from another\nuser's store.\n",
					"type": "String"
				},
				{
					"name": "pretty_json",
					"description": "Determines if the JSON response is formatted for readability (`true`), or displayed on a\nsingle line (`false`). Default is `false`.\n",
					"type": "Boolean"
				}
			]
		},
		"set": {
			"summary": "Set a string or binary value",
			"description": "Sets a string or binary value referenced by the key name. The size of the value can be up to 2M, and the key name length can be up to 256 characters. The default value type is String. ",
			"authRequired": true,
			"instance": true,
			"adminRequired": false,
			"response": {
				"singleElement": true,
				"model": "keyvalues"
			},
			"parameters": [
				{
					"name": "name",
					"description": "The name, or key, for this key-value pair.",
					"type": "String",
					"required": true
				},
				{
					"name": "type",
					"description": "Value type: \"string\" or \"binary\".\n\nDefaults to \"string\".\n",
					"type": "String"
				},
				{
					"name": "value",
					"description": "Value to assoicate with the key.\n\nBinary data can be passed as a binary form part. The REST example shows how to\nsend binary data using curl.\n",
					"type": [
						"String",
						"BinaryData"
					],
					"required": true
				},
				{
					"name": "access_private",
					"description": "Determines whether this key-value is publically readable, or stored in a\nprivate store.\n\nDefault is false (publically readable). If set to true, it sets the key/value stored\nin the current user's private key-value store. Otherwise, it sets the public\nkey-value pair which is readable to everyone.\n",
					"type": "Boolean"
				},
				{
					"name": "su_id",
					"description": "User to create the key-value pair on behalf of.\n\nThe current user must be an application admin to set a key-value pair on\nbehalf of another user.\n",
					"type": "String"
				},
				{
					"name": "pretty_json",
					"description": "Determines if the JSON response is formatted for readability (`true`), or displayed on a\nsingle line (`false`). Default is `false`.\n",
					"type": "Boolean"
				}
			]
		},
		"incrby": {
			"summary": "Increment a Key-Value",
			"description": "Increment the `value` by the given integer value. Not allowed on key-value pairs with binary data.  If the current value in the key-value is not convertable to an integer, the new value replaces the existing value. ",
			"authRequired": true,
			"instance": true,
			"adminRequired": false,
			"response": {
				"singleElement": true,
				"model": "keyvalues"
			},
			"parameters": [
				{
					"name": "name",
					"description": "Name (or key) for the key-value pair.",
					"type": "String",
					"required": true
				},
				{
					"name": "value",
					"description": "Integer value to add to the current value. If a floating point number is\nspecified, any fractional portion is dropped.\n\nIf this value cannot be converted to an integer, the existing value is not\nchanged.\n",
					"type": [
						"String",
						"Number"
					],
					"required": true
				},
				{
					"name": "access_private",
					"description": "Determines whether to update this key-value in the publically readable store\nor in the user's private store.\n\nDefault is false (publically readable).\n",
					"type": "Boolean"
				},
				{
					"name": "su_id",
					"description": "Update the key-value pair on behalf of the identified user.\n\nLogin user must be an admin to update a key-value on behalf of another user.\n",
					"type": "String"
				},
				{
					"name": "pretty_json",
					"description": "Determines if the JSON response is formatted for readability (`true`), or displayed on a\nsingle line (`false`). Default is `false`.\n",
					"type": "Boolean"
				}
			]
		},
		"remove": {
			"canonical": "delete"
		}

	},

	_prepareParams: function prepareParams(method, instance, params, defaultValue) {
		params || (params = {});
		switch (method) {
			case 'update':
				defaultValue.key_value_id = instance.getPrimaryKey();
				return defaultValue;
			case 'delete':
				return {
					key_value_id: instance.getPrimaryKey()
				};
		}
		return defaultValue;
	},

	actions: ["delete", "read"]
});
Example #20
0
	before(function (next) {
		// define your model
		Model = Arrow.Model.extend('post', {
			fields: {
				title: {type: String},
				content: {type: String}
			},
			connector: 'appc.mysql'
		});

		should(Model).be.an.object;

		server.start(function (err) {
			should(err).be.not.ok;

			async.eachSeries([
				'DROP TABLE IF EXISTS post',
				'CREATE TABLE post' +
				'(' +
				'	id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,' +
				'	title VARCHAR(255),' +
				'	content VARCHAR(255)' +
				')',
				'DROP TABLE IF EXISTS super_post',
				'CREATE TABLE super_post' +
				'(' +
				'	id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,' +
				'	title VARCHAR(255),' +
				'	content VARCHAR(255)' +
				')',
				'DROP TABLE IF EXISTS employee',
				'CREATE TABLE employee' +
				'(' +
				'	id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,' +
				'	first_name VARCHAR(255),' +
				'	last_name VARCHAR(255),' +
				'	email_address VARCHAR(255)' +
				')',
				'DROP TABLE IF EXISTS typeTesting',
				'CREATE TABLE typeTesting' +
				'(' +
				'	my_tinyint TINYINT,' +
				'	my_smallint SMALLINT,' +
				'	my_mediumint MEDIUMINT,' +
				'	my_bigint BIGINT,' +
				'	my_int INT,' +
				'	my_integer INTEGER,' +
				'	my_float FLOAT,' +
				'	my_bit BIT,' +
				'	my_double DOUBLE,' +
				'	my_binary BINARY,' +
				'	my_date DATE,' +
				'	my_datetime DATETIME,' +
				'	my_time TIME,' +
				'	my_year YEAR,' +
				'	my_varchar VARCHAR(255),' +
				'	my_char CHAR(5),' +
				'	my_tinyblob TINYBLOB,' +
				'	my_blob BLOB,' +
				'	my_mediumblob MEDIUMBLOB,' +
				'	my_longblob LONGBLOB,' +
				'	my_tinytext TINYTEXT,' +
				'	my_mediumtext MEDIUMTEXT,' +
				'	my_longtext LONGTEXT,' +
				'	my_text TEXT' +
				')'
			], function (query, callback) {
				connector._query(query, function (err) {
					console.error('query failed:');
					console.error(query);
					callback(err);
				}, function (result) {
					callback();
				});
			}, function () {
				server.ignoreDuplicateModels = true;
				connector.createModelsFromSchema();
				next();
			});
		});
	});
Example #21
0
module.exports = Arrow.Model.extend("appc.arrowdb/email", {
	/**
	 * Remove _syncModelsCanUpdateThis property or set it to false if you want to prevent syncModels.js from changing this file.
	 */
	_syncModelsCanUpdateThis: true,

	/**
	 * indicate that the model was generated
	 */
	generated: true,

	/**
	 * if this model is visible
	 */
	visible: false,

	/*
	 Fields for this model.
	 */
	fields: {
	},
	/*
	 Methods for this model.
	 */
	methodMeta: {
		"emailFromTemplate": {
			"summary": "Send Emails",
			"description": "Sends an email to a list of email addresses you specify.   When sending an email, you specify the name of an email template created in Dashboard  (see [Managing Email Templates](http://docs.appcelerator.com/platform/latest/#!/guide/Managing_Email_Templates)), and one or more email recipients. You can optionally specify the email content type ( HTML, plain-text, or multipart), as well as values for any placeholder fields defined by the template. The below examples demonstrate these concepts.  An email template's body can contain HTML-formatted or plain-text content  , or both. When you send an email, you can specify whether the email should be sent  as HTML, plain text, or multipart using the `content_type` parameter.  A multipart email contains both the plain text and HTML versions; which  version is displayed is determined by the recipient's email client.  If the `content_type` parameter is **not** provided in the request, the format is automatically chosen based on the following rules:  * If the email template contains both HTML and plain-text bodies, it will be sent in a multipart format.  * If the email template contains only an HTML body, it will be sent in an HTML format.  * If the email template contains only a plain-text body. it will be sent in plain-text format.        If the `content_type` parameter is provided in the request, then the following must be true:  * If `content_type` is \"html\", then the email template must define an HTML body. * If `content_type` is \"plain\", then the email template must define a plain text body. * If `content_type` is \"multipart\", then the email template must define both HTML and plain text body. ",
			"authRequired": false,
			"instance": true,
			"adminRequired": false,
			"response": {
				"singleElement": true
			},
			"parameters": [
				{
					"name": "template",
					"description": "Name of the email template you have created.\n",
					"type": "String",
					"required": true
				},
				{
					"name": "recipients",
					"description": "Comma separated list of email addresses.",
					"type": "String",
					"required": true
				},
				{
					"name": "content_type",
					"description": "Specifies the email's content-type. The following values are valid:\n\n* \"plain\" &mdash; If specified, the email template must define a plain text body.\n* \"html\" &mdash; If specified, the email template must define an HTML body.\n* \"multipart\" &mdash; If specified, the email template must define both a plain text\n   and HTML body.\n   \nSee [Managing Email Templates](http://docs.appcelerator.com/platform/latest/#!/guide/Managing_Email_Templates)\nfor details on creating email templates.\n",
					"type": "String"
				},
				{
					"name": "from",
					"description": "The sender's email address. \n\n**Notes**:\n  \n  * If you use Google as your SMTP server, the email will always be sent using the email account \n  you used to configure the SMTP service. \n  * Some SMTP service provider require the sender's email address to be present.\n",
					"type": "String"
				},
				{
					"name": "pretty_json",
					"description": "Determines if the JSON response is formatted for readability (`true`), or displayed on a\nsingle line (`false`). Default is `false`.\n",
					"type": "Boolean"
				}
			]
		}
	},

	_prepareParams: function prepareParams(method, instance, params, defaultValue) {
		params || (params = {});
		switch (method) {
			case 'update':
				defaultValue.email_id = instance.getPrimaryKey();
				return defaultValue;
			case 'delete':
				return {
					email_id: instance.getPrimaryKey()
				};
		}
		return defaultValue;
	},

	actions: []
});
Example #22
0
module.exports = Arrow.Model.extend("appc.arrowdb/place", {
	/**
	 * Remove _syncModelsCanUpdateThis property or set it to false if you want to prevent syncModels.js from changing this file.
	 */
	_syncModelsCanUpdateThis: true,

	/**
	 * indicate that the model was generated
	 */
	generated: true,

	/**
	 * if this model is visible
	 */
	visible: true,

	/*
	 Fields for this model.
	 */
	fields: {
		"name": {
			// "originalType": "String",
			"type": String,
			"description": "Place name."
		},
		"address": {
			// "originalType": "String",
			"type": String,
			"description": "Address."
		},
		"city": {
			// "originalType": "String",
			"type": String,
			"description": "City."
		},
		"state": {
			// "originalType": "String",
			"type": String,
			"description": "State."
		},
		"postal_code": {
			// "originalType": "String",
			"type": String,
			"description": "Postal or ZIP code."
		},
		"country": {
			// "originalType": "String",
			"type": String,
			"description": "Country."
		},
		"latitude": {
			// "originalType": "Number",
			"type": Number,
			"description": "Latitude."
		},
		"longitude": {
			// "originalType": "Number",
			"type": Number,
			"description": "Longitude."
		},
		"website": {
			// "originalType": "String",
			"type": String,
			"description": "Website."
		},
		"twitter": {
			// "originalType": "String",
			"type": String,
			"description": "Twitter ID."
		},
		"phone_number": {
			// "originalType": "String",
			"type": String,
			"description": "Phone number."
		},
		"photo": {
			// "originalType": "Photos",
			"type": Array,
			"description": "Primary photo for this place."
		},
		"tags": {
			// "originalType": "Array",
			"type": Array,
			"description": "List of tags for this object."
		},
		"custom_fields": {
			// "originalType": "String,Hash",
			"type": Object,
			"description": "User defined fields. See [Custom Data Fields](#!/guide/customfields)."
		},
		"acls": {
			// "originalType": "Array",
			"type": Array,
			"description": "Single-element array containing the ACL associated with this object, if any."
		},
		"user": {
			// "originalType": "Users",
			"type": Array,
			"description": "Owner of this place object."
		},
		"reviews": {
			// "originalType": "Array",
			"type": Array,
			"description": "List of reviews for this object.  Only present if the object has been reviewed. "
		},
		"reviews_count": {
			// "originalType": "Number",
			"type": Number,
			"description": "Total number of reviews for this object.  Only present if the object has been reviewed. "
		},
		"ratings_count": {
			// "originalType": "Number",
			"type": Number,
			"description": "Total number of reviews for this object that include a rating.  Only present if the object has been reviewed. "
		},
		"ratings_average": {
			// "originalType": "Number",
			"type": Number,
			"description": "Average rating for this object. Only present if the object has been reviewed."
		},
		"ratings_summary": {
			// "originalType": "Hash",
			"type": Object,
			"description": "Breakdown of the number of reviews that specified a given rating value. For example, if your ratings range from 1-5, the ratings summary might look like this:      ratings_summary: {         \"1\" : 1,         \"2\" : 0,         \"3\" : 5,         \"4\" : 50,         \"5\" : 12     }  Only present if the object has been reviewed. "
		},
		"user_id": {
			// "originalType": "",
			"type": String,
			"description": "Specifies the owner of object."
		}
	},
	/*
	 Methods for this model.
	 */
	methodMeta: {
		"show": {
			"summary": "Show a Place",
			"description": "Returns information for the identified place.",
			"authRequired": false,
			"instance": true,
			"adminRequired": false,
			"response": {
				"singleElement": true
			},
			"parameters": [
				{
					"name": "place_id",
					"description": "ID of the place to show.",
					"type": "String",
					"required": true
				},
				{
					"name": "response_json_depth",
					"description": "Nested object depth level counts in the response JSON.\n\nIn order to reduce server API calls from an application, the response JSON may\ninclude not just the identified object, but also\nsome important data related to the returned objects, such as owners and\nreferenced objects.\n\nDefault is 1, valid range is 1 to 8.\n",
					"type": "Number"
				},
				{
					"name": "show_user_like",
					"description": "If set to **true** the Place object in the response will include `\"current_user_liked: true\"`\nif the current user has liked the object. If the user has not liked the object, the \n`current_user_liked` field is not included in the response.\n",
					"type": "Boolean"
				},
				{
					"name": "pretty_json",
					"description": "Determines if the JSON response is formatted for readability (`true`), or displayed on a\nsingle line (`false`). Default is `false`.\n",
					"type": "Boolean"
				}
			]
		},
		"query": {
			"summary": "Custom Query Places",
			"description": "Performs custom query of places with sorting and paginating. Currently you can not query or sort data stored inside array or hash in custom fields.  The following fields can be used for querying and sorting places:  *   `address` : String.  Place address. *   `city` : String.  Place city. *   `state` : String. Place state. *   `country` : String.  Country. *   `user_id` : String. ID of the user who created this place. *   `google_cid` : Google Customer ID (CID) associated with this place. *   `tags_array` : String. Search tags. *   `lnglat` : `[longitude, latitude]`. The Place's default coordinates. You can also store      custom coordinates in a custom field and query for those coordinates separately       (see [Geographic Coordinates in Custom Fields](#!/guide/customfields-section-geographic-coordinates-in-custom-fields)). *   `ratings_average:  Number`.  Place's average rating (see Reviews). *   `ratings_count: Number`. Place's total number of ratings (see Reviews). *   `reviews_count: Number`. Place's total number of reviews (see Reviews). *   `created_at: Date`. Timestamp when the photo was created. *   `updated_at: Date`. Timestamp when the photo was updated.  In ACS 1.1.5 and later, you can paginate query results using `skip` and `limit` parameters, or by including a `where` clause to limit the results to objects whose IDs fall within a specified range. For details, see [Query Pagination](#!/guide/search_query-section-query-pagination).  For details about using the query parameters, see the [Search and Query guide](#!/guide/search_query). ",
			"authRequired": false,
			"instance": true,
			"adminRequired": false,
			"parameters": [
				{
					"name": "page",
					"description": "\nStarting in ACS 1.1.5, page and per_page are no longer supported in query operations. \nApplications should instead use skip and limit \nquery parameters.\n",
					"type": "Number"
				},
				{
					"name": "per_page",
					"description": "\nStarting in ACS 1.1.5, page and per_page are no longer supported in query operations. \nApplications should instead use skip and limit \nquery parameters.\n",
					"type": "Number"
				},
				{
					"name": "limit",
					"description": "The number of records to fetch. The value must be greater than 0, and no greater than \n1000, or an HTTP 400 (Bad Request) error will be returned. Default value of `limit` is 10.\n",
					"type": "Number"
				},
				{
					"name": "skip",
					"description": "The number of records to skip. The value must be greater than or equal to 0, and no greater \nthan 4999, or an HTTP 400 error will be returned. To skip 5000 records or more \nyou need to perform a range-based query. See \nQuery Pagination for more information.\n",
					"type": "Number"
				},
				{
					"name": "where",
					"description": "Constraint values for fields. `where` should be encoded JSON.\n\nIf `where` is not specified, `query` returns all objects.\n",
					"type": "Hash"
				},
				{
					"name": "order",
					"description": "Sort results by one or more fields.\n",
					"type": "String"
				},
				{
					"name": "sel",
					"description": "Selects the object fields to display. Do not use this parameter with `unsel`.\n",
					"type": "Hash"
				},
				{
					"name": "show_user_like",
					"description": "If set to **true**, each Place object in the response includes `\"current_user_liked: true\"`\n if the current user has liked the object. If the user has not liked the object, the \n`current_user_liked` field is not included in the response.\n",
					"type": "Boolean"
				},
				{
					"name": "unsel",
					"description": "Selects the object fields NOT to display. Do not use this parameter with `sel`.\n",
					"type": "Hash"
				},
				{
					"name": "response_json_depth",
					"description": "Nested object depth level counts in the response JSON.\n\nIn order to reduce server API calls from an application, the response JSON may\ninclude not just the objects that are being queried/searched, but also\nsome important data related to the returned objects, such as owners and\nreferenced objects.\n\nDefault is 1, valid range is 1 to 8.\n",
					"type": "Number"
				},
				{
					"name": "pretty_json",
					"description": "Determines if the JSON response is formatted for readability (`true`), or displayed on a\nsingle line (`false`). Default is `false`.\n",
					"type": "Boolean"
				}
			]
		},
		"create": {
			"summary": "Create a Place",
			"description": "Creates a new place object.  To create a place, you must specify at least one of the following: address, city, state, postal_code, country, or geographical coordinates (longitude and latitude). ",
			"authRequired": true,
			"instance": true,
			"adminRequired": false,
			"response": {
				"singleElement": true
			},
			"parameters": [
				{
					"name": "name",
					"description": "Place name.",
					"type": "String",
					"required": true
				},
				{
					"name": "address",
					"description": "Address.",
					"type": "String"
				},
				{
					"name": "city",
					"description": "City.",
					"type": "String"
				},
				{
					"name": "state",
					"description": "State.",
					"type": "String"
				},
				{
					"name": "postal_code",
					"description": "Postal or ZIP code.",
					"type": "String"
				},
				{
					"name": "country",
					"description": "Country.",
					"type": "String"
				},
				{
					"name": "latitude",
					"description": "Latitude.",
					"type": "Number"
				},
				{
					"name": "longitude",
					"description": "Longitude.",
					"type": "Number"
				},
				{
					"name": "website",
					"description": "Website URL.",
					"type": "String"
				},
				{
					"name": "twitter",
					"description": "Twitter ID.",
					"type": "String"
				},
				{
					"name": "phone_number",
					"description": "Phone number.",
					"type": "String"
				},
				{
					"name": "photo",
					"description": "New photo to attach as the primary photo for this place.\n\nWhen you use the `photo` parameter to attach a new photo, you can use the\n[custom resize and sync options](#!/guide/photosizes).\n",
					"type": "Photos"
				},
				{
					"name": "photo_id",
					"description": "ID of an existing photo to attach as the primary photo for this place.\n",
					"type": "String"
				},
				{
					"name": "tags",
					"description": "Comma separated list of tags for this place.\n",
					"type": "String"
				},
				{
					"name": "custom_fields",
					"description": "User defined fields. See [Custom Data Fields](#!/guide/customfields).",
					"type": [
						"String",
						"Hash"
					]
				},
				{
					"name": "acl_name",
					"description": "Name of an ACLs to associate with this place object.\n\nAn ACL can be specified using `acl_name` or `acl_id`. The two parameters are\nmutually exclusive.\n",
					"type": "String"
				},
				{
					"name": "acl_id",
					"description": "ID of an ACLs to associate with this place object.\n\nAn ACL can be specified using `acl_name` or `acl_id`. The two parameters are\nmutually exclusive.\n",
					"type": "String"
				},
				{
					"name": "su_id",
					"description": "User ID to create this place on behalf of.\n\nThe current login user must be an application admin to create a place on\nbehalf of another user.\n",
					"type": "String"
				},
				{
					"name": "pretty_json",
					"description": "Determines if the JSON response is formatted for readability (`true`), or displayed on a\nsingle line (`false`). Default is `false`.\n",
					"type": "Boolean"
				}
			]
		},
		"delete": {
			"summary": "Delete a Place",
			"description": "Deletes a place.  Only the user who created the place can delete it.  The primary photo associated with the object is not deleted.  An application admin can delete any Place object. ",
			"authRequired": true,
			"instance": true,
			"adminRequired": false,
			"response": {
				"singleElement": true
			},
			"parameters": [
				{
					"name": "place_id",
					"description": "ID of the place to delete.",
					"type": "String",
					"required": true
				},
				{
					"name": "su_id",
					"description": "User ID to delete the Place object on behalf of. The user must be the creator of the object.\n\nThe current login user must be an application admin to delete a Place object on\nbehalf of another user.\n",
					"type": "String"
				},
				{
					"name": "pretty_json",
					"description": "Determines if the JSON response is formatted for readability (`true`), or displayed on a\nsingle line (`false`). Default is `false`.\n",
					"type": "Boolean"
				}
			]
		},
		"update": {
			"summary": "Update a Place",
			"description": "Any of the parameters used to Create a Place can be used to update it as well. Only the user that created the place can update it.  An application admin can update any place object. ",
			"authRequired": true,
			"instance": true,
			"adminRequired": false,
			"response": {
				"singleElement": true
			},
			"parameters": [
				{
					"name": "place_id",
					"description": "ID of the place to delete.",
					"type": "String",
					"required": true
				},
				{
					"name": "name",
					"description": "Place name.",
					"type": "String"
				},
				{
					"name": "address",
					"description": "Address.",
					"type": "String"
				},
				{
					"name": "city",
					"description": "City.",
					"type": "String"
				},
				{
					"name": "state",
					"description": "State.",
					"type": "String"
				},
				{
					"name": "postal_code",
					"description": "Postal or ZIP code.",
					"type": "String"
				},
				{
					"name": "country",
					"description": "Country.",
					"type": "String"
				},
				{
					"name": "latitude",
					"description": "Latitude.",
					"type": "Number"
				},
				{
					"name": "longitude",
					"description": "Longitude.",
					"type": "Number"
				},
				{
					"name": "website",
					"description": "Website URL.",
					"type": "String"
				},
				{
					"name": "twitter",
					"description": "Twitter ID.",
					"type": "String"
				},
				{
					"name": "phone_number",
					"description": "Phone number.",
					"type": "String"
				},
				{
					"name": "photo",
					"description": "New photo to attach as the primary photo for this place.\n\nWhen you use the `photo` parameter to attach a new photo, you can use the\n[custom resize and sync options](#!/guide/photosizes).\n",
					"type": "Photos"
				},
				{
					"name": "photo_id",
					"description": "ID of an existing photo to attach as the primary photo for this place.\n",
					"type": "String"
				},
				{
					"name": "tags",
					"description": "Comma separated list of tags for this place.\n",
					"type": "String"
				},
				{
					"name": "custom_fields",
					"description": "User defined fields. See [Custom Data Fields](#!/guide/customfields).",
					"type": [
						"String",
						"Hash"
					]
				},
				{
					"name": "acl_name",
					"description": "Name of an ACLs to associate with this place object.\n\nAn ACL can be specified using `acl_name` or `acl_id`. The two parameters are\nmutually exclusive.\n",
					"type": "String"
				},
				{
					"name": "acl_id",
					"description": "ID of an ACLs to associate with this place object.\n\nAn ACL can be specified using `acl_name` or `acl_id`. The two parameters are\nmutually exclusive.\n",
					"type": "String"
				},
				{
					"name": "su_id",
					"description": "User ID to update the Place object on behalf of. The user must be the creator of the object.\n\nThe current login user must be an application admin to update a Place object on\nbehalf of another user.\n",
					"type": "String"
				},
				{
					"name": "pretty_json",
					"description": "Determines if the JSON response is formatted for readability (`true`), or displayed on a\nsingle line (`false`). Default is `false`.\n",
					"type": "Boolean"
				}
			]
		},
		"batchDelete": {
			"summary": "Deletes multiple Places objects.",
			"description": "Deletes Places objects that match the query constraints provided in the `where` parameter. If no `where` parameter is provided, all Places objects are deleted.  Note that an HTTP 200 code (success) is returned if the call completed successfully but the query matched no objects.  For performance reasons, the number of objects that can be deleted in a single batch delete  operation is limited to 100,000.  The matched objects are deleted asynchronously in a separate process.       Any primary photos associated with the matched objects are not deleted.  You must be an application admin to run this command.         ",
			"authRequired": true,
			"instance": true,
			"adminRequired": true,
			"response": {
				"singleElement": true
			},
			"parameters": [
				{
					"name": "where",
					"description": "Encoded JSON object that specifies constraint values for Places objects to delete.\nIf not specified, all Places objects are deleted.\n",
					"type": "Hash"
				}
			]
		},
		"search": {
			"summary": "Search Places",
			"description": "Returns the list of places that have been added to the app, sorted by search relevancy.  Optionally, `latitude` and `longitude` can be given to return the list of places starting from a particular location. To bound the results within a certain radius (in km) from the starting coordinates, add the `distance` parameter. `q` can be given to search by place name.  If you have provided a starting latitude and longitude for place search, each result will return a distance to the starting point in km. ",
			"authRequired": false,
			"instance": true,
			"adminRequired": false,
			"parameters": [
				{
					"name": "page",
					"description": "Request page number, default is 1.",
					"type": "Number"
				},
				{
					"name": "per_page",
					"description": "Number of results per page, default is 10.",
					"type": "Number"
				},
				{
					"name": "response_json_depth",
					"description": "Nested object depth level counts in the response JSON.\n\nIn order to reduce server API calls from an application, the response JSON may\ninclude not just the objects that are being queried/searched, but also\nsome important data related to the returned objects, such as owners and\nreferenced objects.\n\nDefault is 1, valid range is 1 to 8.\n",
					"type": "Number"
				},
				{
					"name": "latitude",
					"description": "Latitude to center search on.",
					"type": "Number"
				},
				{
					"name": "longitude",
					"description": "Longitude to center search on.",
					"type": "Number"
				},
				{
					"name": "distance",
					"description": "Distance in km to search from the identified center point.",
					"type": "Number"
				},
				{
					"name": "q",
					"description": "Space-separated list of keywords used to perform full text search on place name and tags.",
					"type": "String"
				},
				{
					"name": "pretty_json",
					"description": "Determines if the JSON response is formatted for readability (`true`), or displayed on a\nsingle line (`false`). Default is `false`.\n",
					"type": "Boolean"
				}
			]
		},
		"remove": {
			"canonical": "delete"
		}
		
	},

	_prepareParams: function prepareParams(method, instance, params, defaultValue) {
		params || (params = {});
		switch (method) {
			case 'update':
				defaultValue.place_id = instance.getPrimaryKey();
				return defaultValue;
			case 'delete':
				return {
					place_id: instance.getPrimaryKey()
				};
		}
		return defaultValue;
	},

	actions: ["read","create","delete","update"]
});