Skip to content

Instantly share code, notes, and snippets.

// SUMMARY
// 1. New DataStore type will replace the problematic DataStoreType.CACHE
// 2. DataStoreType.CACHE will be deprecated
// 3. The new DataStore type will be called DataStore.AUTO
// 4. DataStoreType.AUTO will be the new default
// AUTO data store creation
// The AUTO data store will favor operations on the network first
// It will only resolve to use the local data store if the network operation cannot complete successfully
var store = DataStore.Collection("workorders", DataStoreType.AUTO, KinveyClient.SharedClient);
@ivanstoyanov
ivanstoyanov / onPreSave.js
Last active August 29, 2015 14:06
Twillio sample
function onPreSave(request,response,modules){
var accountSid = ""; //TODO - your account Sid
var authToken = ""; //TODO - your auth token
var rootURL = "https://api.twilio.com/2010-04-01/Accounts/";
var resourceURL = rootURL + accountSid + "/SMS/Messages.json";
var fromNumber = ""; //TODO - source number
var toNumber = ""; //TODO - destination number
var message = "Hi!";
<html ng-app=”MyApp”>
<script>
var myApp = angular.module("MyApp", ["kinvey"]);
myApp.run(function($kinvey) {
$kinvey.init({
appKey : "App Key",
appSecret : "App Secret"
});
});
function onPostSave(request,response,modules){
var i, to, logger = modules.logger, email = modules.email;
for (i = 0; i < request.body.to.length; i++){
to = request.body.to[i];
logger.info("Sending e-mail to: " + to);
email.send('[email protected]',
to,
request.body.subject,
request.body.body,
request.body.reply_to);
function onPreFetch(request, response, modules){
response.body = {"hello": "world"};
response.complete(200);
}
var connectString = "mongodb://user:pass@host:port,host:port,host:port/admin?replicaSet=myset&autoReconnect=true&connectTimeoutMS=1500&socketTimeoutMS=3000";
var mongo = require('mongodb');
var async = require('async');
var admin_db;
var interval = 6000;
var db1;
var db2;
var simpleQuery = function(callback) {
if (db1==null) {
var connectString = "mongodb://user:password@hostname_1:30000,hostname_2:30001,hostname_3:30002/admin?replicaSet=myset&autoReconnect=true";
var mongo = require('mongodb');
var async = require('async');
var admin_db;
var db1;
var db2;
var simpleQuery = function(callback) {
if (db1==null) {
function onPostSave(request, response, modules) {
var to, logger = modules.logger, email = modules.email, body = request.body;
for (var i = 0; i < body.invitees.length; i++){
/* assumes the following request JSON body
{
"invitees": ["invitee1@gmail.com", "[email protected]"],
"subject": "New invitation",
"body": "You are invited to this awesome new event. Hope you can make it",
"reply_to": "[email protected]"
}*/
@ivanstoyanov
ivanstoyanov / bl_example.js
Created December 11, 2012 04:49
BL example
function onPostSave(request, response, modules) {
var to, logger = modules.logger, email = modules.email, body = request.body;
for (var i = 0; i < body.invitees.length; i++){
/* assumes the following request JSON body
{
"invitees": ["invitee1@gmail.com", "[email protected]"],
"subject": "New invitation",
"body": "You are invited to this awesome new event. Hope you can make it",
"reply_to": "[email protected]"
}*/
@ivanstoyanov
ivanstoyanov / mongopatch.json
Created June 22, 2012 21:21
npm git dependency
"dependencies": {
"mongodb": "git://github.com/Kinvey/node-mongodb-native.git"
}