windows


Windows azure mobile service script


i have problem how to support my request from mobile service in Windows Azure.
Problem:
How can I check, if my respond to client from server have any record or no. I have this, but it didin't work
function read(query, user, request) {
if (query.take(recordCount) > 0) {
request.respond(200, "Exist");
} else {
request.respond(500, "ERROR");
}
Here's an example of looking at the results of the query:
function read(query, user, request) {
request.execute( {success: function(results) {
console.log(results);
request.respond(200, results);
}, error: function(error) {
console.log('error: ', error);
request.respond(500);
}});
}
Inside the success block you can check to make sure results is not empty and reply with a 200 if there are results or 500 if there aren't. If you don't want to execute the full read query, you could alternatively use the mssql module to execute a custom sql statement (i.e. select count(*) from tablename).
In addition to what #Chris suggested, you can also use the includeTotalCount() function, along with a take(0) (if you only care about the number of results, not the results themselves), to only count the items which would be returned in the query:
function read(query, user, request) {
query.includeTotalCount(); // tell me how many items there are
query.take(0); // but don't bother returning them
request.execute({
success: function(results) {
if (results.totalCount > 0) {
request.respond(200, { status: 'Item exists' });
} else {
request.respond(500, { status: 'ERROR' });
}
}
});
}
Or if really all you want to know is whether there are any results or not, you can even skip the includeTotalCount call, and just force the response to return up to 1 result with a take(1) call:
function read(query, user, request) {
query.take(1); // return at most one item
request.execute({
success: function(results) {
if (results.length > 0) {
request.respond(200, { status: 'Item exists' });
} else {
request.respond(500, { status: 'ERROR' });
}
}
});
}

Related Links

install natlink and dragonfly for python2.7 in windows10
python setup.py install - fails with error 5: permission denied
Are there Powershell cmdlets that install and remove Windows drivers?
Does FindWindow work in FMX?
How can i draw to or add a custom button to every window of all applications?
How do I get my Windows7 symlink to execute from command line?
Searching static data using Windows Search Service with IIS
How to sync Time with NTP server on windows
Assembly reference issue when using shared project from iOS and Android Xamarin projects
Changing the image on a button when clicked xaml
Windows Explorer start notification
Is it possible to reinstall winodows with same key came with the machine [closed]
Vagrant on Windows 10 fails with Protocol error
File::Spec->catpath does not work for Windows
Batch file to run other batch files with parameters
Find opened process in Windows batch

Categories

HOME
windows
cygwin
grok
assembly
gdb
3d
jwplayer
sitecore
carousel
babeljs
echo
google-admin-sdk
webix
discrete-mathematics
favicon
linear-algebra
dreamweaver
fileserver
asp.net-mvc-viewmodel
foreign-keys
jmp
connector
symbols
backpack-for-laravel
gulp-watch
roslyn
qliksense
scriptella
dynamically-generated
roundup
google-api-client
maze
syntax-highlighting
8051
spotipy
comparable
sqlpackage
autodesk-designautomation
event-flow
record
reactjs.net
reverse
wurfl
sessionstorage
password-protection
ods
resolution
wmp
install.packages
congestion-control
signal-strength
apache-directory
gitlist
edit
avx
arules
sandcastle
pocketsphinx-android
xcode-server
lrs
google-cloud-console
myspace
appscale
kango-framework
gcloud-ruby
beanstalk
false-sharing
iced-coffeescript
ocra
zend-currency
code-documentation
pseudo-class
iso-prolog
entry-point
ss7
grails-domain-class
matrix-inverse
ray
ios8-extension
mutual-authentication
cocoalibspotify-2.0
printdialog
inappsettingskit
nebula
time.h
server-administration
sqlclr
convention
promotion-code
jqote
appledoc
ruby-1.8
jqueryform
folding
duplex
echo3

Resources

Encrypt Message



code
soft
python
ios
c
html
jquery
cloud
mobile