Releases: andrei-markeev/camljs
Release 2.13
Changes
- It is now possible to start with
<Query>
tag, e.g.new CamlBuilder.Query().ToString()
(see #16) - Calling
ToString()
multiple times will no longer cause different output (see #24) - Fix
BooleanField.NotEqualTo
(thanks to @viceice) - Strong types for
ThenBy
andThenByDesc
(thanks to @viceice) - Smaller library size
Potentially breaking changes
.Membership
syntax that has been deprecated for many years, was finally removed! 😄 Instead ofUserField("AssignedTo").Membership.SPGroup(10)
, useUserField("AssignedTo").IsInSPGroup(10)
- CamlJs no longer polyfills
SP.XmlWriter
andSys.StringBuilder
Release 2.12.1
Update the xmldom
library because of a security vulnerability (see #44)
Note: this dependency is used only in Node.js, if you're using camljs from client-side, you can safely skip this release.
Release 2.12.0
Release 2.11.0
Release 2.10.0
Added support for Aggregations and GroupLimit attribute in GroupBy clause.
Example:
var query = new CamlBuilder()
.View([
"ID",
{ count: "Country" },
{ avg: "FlightCost" }
])
.Query()
.GroupBy("Country", true, 100)
.ToString()
results in the following CAML:
<View>
<ViewFields>
<FieldRef Name="ID" />
</ViewFields>
<Aggregations Value="On">
<FieldRef Name="Country" Type="COUNT" />
<FieldRef Name="FlightCost" Type="AVG" />
</Aggregations>
<Query>
<GroupBy Collapse="TRUE" GroupLimit="100">
<FieldRef Name="Country" />
</GroupBy>
</Query>
</View>
Note: Aggregations should be used with RenderListData endpoint.
Release 2.9.0
Node.js support
It is now possible to use CamlJs in modern npm-based web development.
For example, like this:
npm i camljs -S
and then:
var CamlBuilder = require('camljs');
console.log(new CamlBuilder().View().ToString());
ES6 syntax also supported:
import * as CamlBuilder from 'camljs';
console.log(new CamlBuilder().View().ToString());
SPFx
SPFx example added.
Release 2.8.2
Now it is possible to create nested joins.
For this purpose, optional 3rd parameter fromList of LeftJoin
/InnerJoin
can be used:
/** Join the list you're querying with another list.
Joins are only allowed through a lookup field relation.
@param lookupFieldInternalName Internal name of the lookup field, that points to the list you're going to join in.
@param alias Alias for the joined list
@param fromList (optional) List where the lookup column resides - use it only for nested joins */
InnerJoin(lookupFieldInternalName: string, alias: string, fromList?: string): IJoin;
/** Join the list you're querying with another list.
Joins are only allowed through a lookup field relation.
@param lookupFieldInternalName Internal name of the lookup field, that points to the list you're going to join in.
@param alias Alias for the joined list
@param fromList (optional) List where the lookup column resides - use it only for nested joins */
LeftJoin(lookupFieldInternalName: string, alias: string, fromList?: string): IJoin;
For example, let's say we have 3 SharePoint lists:
Orders
Title
Description
Amount
Customer (lookup to Customers -> Title)
Customers
Title
City (lookup to Cities -> Title)
Cities
Title
Then, we can extend Orders with City of the customer using the following CamlJs query:
var query = new CamlBuilder().View(["Title", "City"])
.LeftJoin("Customer", "customersList")
.LeftJoin("City", "citiesList", "customersList")
.Select("Title", "City")
.Query()
.ToString();
Result:
<View>
<ViewFields>
<FieldRef Name="Title" />
<FieldRef Name="City" />
</ViewFields>
<Joins>
<Join Type="LEFT" ListAlias="customersList">
<Eq>
<FieldRef Name="Customer" RefType="ID" />
<FieldRef Name="ID" List="customersList" />
</Eq>
</Join>
<Join Type="LEFT" ListAlias="citiesList">
<Eq>
<FieldRef Name="City" RefType="ID" List="customersList" />
<FieldRef Name="ID" List="citiesList" />
</Eq>
</Join>
</Joins>
<ProjectedFields>
<Field ShowField="Title" Type="Lookup" Name="City" List="citiesList" />
</ProjectedFields>
<Query />
</View>
Release 2.8.1
Bugfix for View.Query.OrderBy scenario. Fixes #2