dlid / camlsql-js Goto Github PK
View Code? Open in Web Editor NEWJavascript CAML Query library using SQL queries
License: MIT License
Javascript CAML Query library using SQL queries
License: MIT License
Make sure you can use proper list names where needed.
Maybe require [ ] when it contains spaces? That's a good plan!
Let's not allow spaces in a joined list alias..
SELECT * FROM ListName -> "ListName"
SELECT * FROM [List Name] -> "List Name"
SELECT * FROM List Name -> Not ok
SELECT * FROM [List Name]
JOIN FavoriteBook ON [List Name].Favourite_book
-> ok
SELECT * FROM [List Name]
JOIN FavoriteBook ON List Name.Favourite_book
-> error
SELECT * FROM [List Name]
JOIN FavoriteBook ON [List Name].Favourite_book
-> ok
vkbeautify.xml(camlsql.prepare("SELECT * FROM Movies WHERE (Title = ? AND Title LIKE ?) AND (Fun = ? OR Scary < ?)",["summer", 'did', 10, 6,0,6]).getXml());
This query creates the following parsed object.
The first two "groups" are the same. There should only be one of those.
[{
"type": "group",
"value": "Title = ? AND Title LIKE ?",
"operator": "and",
"items": [{
"type": "statement",
"operator": "and",
"field": "Title",
"macro": "@param0",
"comparison": "eq"
}, {
"type": "statement",
"operator": "and",
"field": "Title",
"macro": "@param1",
"comparison": "like"
}]
}, {
"type": "group",
"value": "(Title = ? AND Title LIKE ?)",
"operator": "and",
"items": [{
"type": "statement",
"operator": "and",
"field": "(Title",
"macro": "@param2",
"comparison": "eq"
}, {
"type": "statement",
"operator": "and",
"field": "Title",
"macro": "@param3",
"comparison": "like"
}]
}, {
"type": "group",
"value": "Fun = ? OR Scary < ?",
"operator": "and",
"items": [{
"type": "statement",
"operator": "and",
"field": "Fun",
"macro": "@param4",
"comparison": "eq"
}, {
"type": "statement",
"operator": "or",
"field": "Scary",
"macro": "@param5",
"comparison": "lt"
}]
}]
camlsql.prepare("SELECT * FROM Listan WHERE a = @meh AND y is null", {"@meh" : "test"});
You get the error:
[camlsql] You can not mix named macros and ?
When I write WHERE Preamble=?
(with no spaces around =) then the field name is cut.
WHERE Preamble=?
(with no spaces around =) then the field name is cut to <FieldRef Name="Preambl" />
Preamble<?
the comparison is not recognized at allPreamble>?
the comparison becomes EQUAL and not GTPreambleLIKE
seems to work. But it probably should not... Same thing with Preamblein?
or walkin?
. Field name will be "Preamble" with an IN clauseSELECT * FROM [Decisions] WHERE [Title] LIKE ? AND (([Motivation] IS NULL OR [IsBoss] = ?) or P = ?)
works fine
But SELECT * FROM [Decisions] WHERE [Title] LIKE ? AND ( ([Motivation] IS NULL OR [IsBoss] = ?) or P = ?)
does not (See the SPACE character in the Motivation parenthesises.
Greetings again! How useful do you think a library like this would be if it could expand to support the other CRUD list operations in sharepoint? I love how caml sql supports the select statement, but I think it would be a real quantum leap if it could also support inserts, updates, and deletes.
How popular/beneficial do you think that capability would be? From what I've seen, there's a few other SP JS libraries that allow you to do similar things, but their syntax is broken into something resembling LINQ methods. (I'm not asking you to develop this capability, I'm really just asking your opinion, and I would take care of the dev part myself :)
When using encoded field names in the query it would make sense to be able to access properties using the non-encoded name in the result.
SELECT [Title], [Båtfärg] FROM ListOfBoats`
<script>
camlsql.prepare(...).exec(function(err, rows) {
// I want to be able to use
var color = rows[0]["Båtfärg"];
// Instead of
var color = rows[0].B_x00e5_tf_x00e4_rg
});
</script>
Or I will have to know the encoded filename anyway and then what's the point of being able to use the non-encoded filename in the SQL-query?
Complex groups will break
SELECT * FROM [Decisions] WHERE [Title] LIKE ? AND (([Motivation] IS NULL AND [IsBoss] = ?) or (P = ? AND P2 < ?))
getDateFromTextualRepresentation("week start", new Date(1980, 03, 04));
supposed to be 31st of april 00:00:00 but returns
Sun Mar 30 1980 00:00:00 GMT+0100 (Central Europe Standard Time)
same with week end
var d = camlsql.testonly.getDateFromTextualRepresentation("week end", new Date(1980, 03, 04));
How should ( and ) be encoded? It's not encoded at all now
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.