UNPKG

dynamicsnode

Version:

Create simple scripts to interact with Dynamics CRM using Node.js

110 lines (109 loc) 5.88 kB
export declare class Fetch { entityName: string; filter: Filter; attributes: string[]; /** Default Constructor * @class Fetch * @classdesc Provides properties and methods to create FetchXml queries * @param entityName {string} Optional. Name of the entity which the query is for * @param attr {string|boolean|string[]} Optional. Either a column name, or a list of column names, or a boolean value indicating that all the attribute values want to be retrieved. The default value is null, and means that only the primary attribute will be retrieved. * @param filterConditions {object} Optional. Object that describes conditions in an JSON notation. More Info: {@link Fetch#setFilter} * @example <caption>Create an empty FetchXml</caption> * var fetch = new Fetch(); * console.log(fetch.toString()); // outputs: <fetch><entity></entity></fetch> * @example <caption>Create a Fetch query for the "account"" entity, with 3 attributes and one filter</caption> * var fetch = new Fetch("account",["description","createdon","ownerid"],{name:"acme"}); * @example <caption>Create a Fetch query for the "account"" entity, with all attributes and one filter</caption> * var fetch = new Fetch("account",true,{name:"acme"}); */ constructor(entityName?: string, attr?: string | boolean | string[], filterConditions?: any); toString(): any; private serializeAttributes(value, writer); /** * Sets the filter criteria of the current <i>FetchXml</i> with the specified values. * * The specified value can be eiher a {@link Filter} object or a conditions object. * * A conditions object is a Javascript object where every property represents a condition. * * If the object contains a property, and that property contains a simple value, like an string or a number, that means property equals to value. * * If you need to specify another operator, then you have to use the form: {attribute:{$operator:value}} * * If the value is an array, then the $in operator is used. * * If the value is a null value, then the nulloperator is applied. For example: {name:null} will retrieve all the records where the name is null. * * @method Fetch#setFilter * @param filterCondition {Filter|object} A Filter object or a Conditions specified in JSON notation. * * @see Build queries with FetchXML: {@link https://msdn.microsoft.com/en-us/library/gg328332.aspx} * * @example <caption>When the simple syntax is used {name:value} then the $eq operator is used. The following filter retrieves all records where the attribute <i>name</i> is equals to "myAccount"</caption> * var cond = {name:"myAccount"}; * @example <caption>The following retrieves all records where the attribute <i>name</i> is equals to "myAccount" <b>AND</b> the createdon date is equals to the system date</caption> * var cond = {name:"myAccount", createdon:new Date()} * @example <caption>If you need to specify additional operators, then use a subobject with the operator name. The following retrieves all records where the attribute <i>name</i> begins with "contoso%" and the attribute <i>createdon</i> is bigger than the current date</caption> * var cond = {name:{$like:"contoso%"}, createdon:{$bt:new Date()}} * @example <caption>Currently supported operators:</caption> * $eq, $neq, $gt, $ge, $le, $lt, $like, $notlLike, $in, $notIn, $between, $notBetween * @example <caption>If the value is an array, then the <i>in</i> operator is applied. The wollowing means: where name is one of contoso, acme or cycleworks</caption> * var cond = {name:["contoso", "acme", "cycleworks"]}; * @example <caption>To specify the null operator, use a null value next to the attribute name. The following will retrieve all the records where the name is null.</caption> * var cond = {name:null}; * @example <caption>To specify the Not Null operator, use a the "$notNull" value next to the attribute name. The following will retrieve all the records where the name is Not null.</caption> * var cond = {name:"$notNull"}; */ setFilter(filterConditions: any): void; setAttributes(attributes: boolean | string | string[]): void; private serializeValue(value); private serializeConditions(filter, writer); private operatorNames; private operatorJsonNames; private NOT_NULL_OPERATOR; private convert(conditionExpression); } /** * Filter Type Values * @typedef {object} FilterTypes * @property {number} And Indicates that all the values in the conditions must be true * @property {number} Or Indicates that only one of the conditions must be true */ export declare enum FilterTypes { And = 0, Or = 1, } export declare class Filter { conditions: Array<Condition>; filterType: FilterTypes; /** * Default Constructor * @class Filter * @classdesc Describes a Filter in a {@link Fetch} query. */ /** @member Filter#conditions {Condition[]} Contains the conditions of this filter */ /** @member Filter#filterType {FilterTypes} Indicates if the filter is an And or Or filter */ constructor(conditions?: Array<Condition>, filterType?: FilterTypes); } export declare enum Operators { Equal = 0, NotEqual = 1, GreaterThan = 2, GreaterEqual = 3, LessEqual = 4, LessThan = 5, Like = 6, NotLike = 7, In = 8, NotIn = 9, Between = 10, NotBetween = 11, Null = 12, NotNull = 13, } export declare class Condition { attribute: string; operator: Operators; values: Array<any>; constructor(attribute?: string, operator?: Operators, values?: Array<any>); }