Quantcast
Channel: CamlJs: SharePoint JavaScript Caml Builder
Viewing all articles
Browse latest Browse all 199

Updated Wiki: What's new in Release 2.0

$
0
0

What's new in Release 2.0

Bracket expressions and partial query generation

This is the main improvement comparing to the version 1.0, where you couldn't create complex queries because of lack of bracket expressions support.

Two new methods were added to the builder chain in order to support that: Any& All.

/** Adds And clauses to the query. Use for creating bracket-expressions in conjuction with CamlBuilder.Expression(). */
All(...conditions: IExpression[]): IExpression;

 

/** Adds Or clauses to the query. Use for creating bracket-expressions in conjuction with CamlBuilder.Expression(). */
Any(...conditions: IExpression[]): IExpression;


You can use these methods in conjunction with CamlBuilder.Expression() for creating bracket expressions, for example like this:

var camlQuery = new CamlBuilder().Where().Any(
    CamlBuilder.Expression().TextField("Email").EqualTo("support@google.com"), 
    CamlBuilder.Expression().TextField("Email").EqualTo("plus@google.com"), 
    CamlBuilder.Expression().TextField("Title").BeginsWith("[Google]"), 
    CamlBuilder.Expression().TextField("Content").Contains("Google")
).ToString();


As a side effect, you can now create parts of your query separately via CamlBuilder.Expression(), and then merge them together at some point later. Also you can useCamlBuilder.Expression() for defining CAMLQuery attribute in SPServices.

Better Intellisense

Intellisense significantly improved: now different types of fields have different sets of comparison options. Field usage is made more obvious.

  1. LookupField element improved. No more misleading "casting" of lookups to the target field types: now lookup fields expose methodsId() and ValueAs<type of field>().
  2. BooleanField element added for fields of boolean type.
  3. UrlField element added for fields of type URL.
  4. DateRangesOverlap element improved. It turns out, you cannot use this element in CSOM, because CSOM ignores QueryOptions element. But you still can use DateRangesOverlap with SPServices.
  5. UserField element improved.

Migration from version 1.0 to version 2.0

None of old elements were removed, but syntax is now more strict, thus in some cases it is possible that some migration will be necessary. Please, post your problems to discussions, if you will have any.

Also, please keep in mind that some elements were marked as deprecated:

  1. LookupIdField element marked as deprecated and will be removed in the next major release. Please, useLookupField(...).Id() instead.
  2. Membership element marked as deprecated and will be removed in the next major release. Functionality ofMembership element was replaced with set of methods under UserField element.

TypeScript implementation

CamlBuilder is now implemented in TypeScript and thus can be used seamlessly by Typescript developers. Of course, you can still use JavaScript version for pure JS development.

Internally, TypeScript unit tests (tsUnit) are now used, helping to make the library much more stable. New tests are added.

Nuget

CamlBuilder is now available via Nuget.

JavaScript:

PM> Install-Package CamlJs



TypeScript definitions:

PM> Install-Package camljs.TypeScript.DefinitelyTyped

Viewing all articles
Browse latest Browse all 199

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>