In a similar vein to a previous question I've asked, I'm wondering A) how to pass individual data attributes to a server extension and B) how to access those data attributes from inside the server extension source code. As a sidebar (and not necessarily the main purpose of this question), is it possible to return an array of FatFractal objects from a server extension? I am using the FatFractal JavaScript SDK in my client application.
Basically, I am creating a simple search utility where the input parameter will be passed to a server extension, and the server extension will return an array of FFUser objects matching the search condition.
FFDL:
CREATE EXTENSION /SearchUsers AS javascript:require('scripts/Search').searchUsers();
Application JS Code:
function findUsers() {
if(!ff.loggedIn()) {
alert("You must be logged in to search for users.");
}
else {
var searchCriteria = $("#input-user-search").val();
// pass 'searchCriteria' to 'SearchUsers' extension
// acquire handle to 'matchedUsers' returned from 'SearchUsers'
...
}
}
Server Extension JS Code:
var ff = require('ffef/FatFractal');
function searchUsers() {
var matchedUsers; // an array of FFUser objects
var searchInput; // the search criteria
// acquire handle to 'searchCriteria' passed from client app to assign to 'searchInput'
...
// return 'matchedUsers' to client app
}
...
exports.searchUsers = searchUsers;
Again, the commented sections are those which I need some clarification with. The rest of the implementation logic I believe I have figured out. Thanks in advance for any help!