module.exports = function (opts) {
	return persist.define("taxi_positions", {
	  "taxi_id": type.INTEGER,
	  "latitude": type.REAL,
	  "longitude": type.REAL
	});
  };
Example #2
0
  module.exports = function (opts) {
	return persist.define("areas", {
	  "area_id": type.INTEGER,
	  "address": type.STRING,
	  "latitude": type.REAL,
	  "longitude": type.REAL
	});
  };
  module.exports = function (opts) {
	return persist.define("bookings", {
	  "booking_id": type.INTEGER,
	  "taxi_id": type.INTEGER,
	  "area_id": type.INTEGER,
	  "booking_time": type.DATETIME
	});
  };
Example #4
0
File: Demand.js Project: hsrky/btw
var persist = require("persist"),
    type = persist.type;
    
module.exports = persist.define("demand", {
    "demand_level": type.INTEGER, // 0 (no demand) - 10 (very high demand)
    "timerange_l": type.STRING,   // lower bound of timerange, e.g 14:00
    "timerange_h": type.STRING,   // higher bound of timerange, e.g. 16:00
    "weekend" : type.BOOLEAN,     // true to indicate this demand is valid only on weekend
    //"holiday" : type.BOOLEAN    // not implement
});
Example #5
0
var persist = require("persist");
var type = persist.type;

module.exports = persist.define("Keyword", {
  "name": { type: type.STRING }
});
Example #6
0
var persist = require("persist");
var type = persist.type;

module.exports = persist.define("Category", {
  "name": { type: type.STRING }
});
Example #7
0
var persist = require("persist");
var Category = require("./category");
var Keyword = require("./keyword");
var type = persist.type;

module.exports = Blog = persist.define("Blog", {
  "created": { type: type.DATETIME, defaultValue: function() { return new Date() } },
  "lastUpdated": { type: type.DATETIME },
  "title": { type: type.STRING },
  "body": { type: type.STRING }
})
  .hasOne(Category)
  .hasMany(Keyword, { through: "blogs_keywords" });

Blog.onSave = function(obj, connection, callback) {
  obj.lastUpdated = new Date();
  callback();
}
Example #8
0
var persist = require("persist");
var type = persist.type;

var Tag = require("./tag");

module.exports = persist.define("Image", {
  "title": type.STRING,
  "referer": type.STRING,
  "originalUrl": type.STRING,  
  "cachedUrl": type.STRING,
  "thumbUrl": type.STRING,
  "ratio": type.REAL,
  "complexity": type.REAL,
}).hasMany(Tag, { through:'images_tags' });
Example #9
0
'use strict';

var persist = require('persist');
var type = persist.type;

var Unit = module.exports = persist.define("unit", {
  "name": type.STRING
});

Unit.findOrAddByName = function(conn, name, callback) {
  return Unit
    .where('name = ?', name)
    .first(conn, function(err, unit) {
      if (err) {
        return callback(err);
      }
      if (unit) {
        return callback(null, unit);
      }
      unit = new Unit({
        name: name
      });
      return unit.save(conn, callback);
    });
};
Example #10
0
"use strict";

var Artefact;
var persist = require("persist");
var type = persist.type;

module.exports = Artefact = persist.define("Artefact", {
  "lastUpdated": { type: type.DATETIME },
  "version": { type: type.STRING },
  "buildUrl": { type: type.STRING },
  "artefactPath": { type: type.STRING }
});

Artefact.onSave = function (obj, connection, callback) {
  obj.lastUpdated = new Date();
  callback();
};
Artefact.validate = function (obj, callback) {

  var validateVersions = function (err, pipeline) {
    pipeline.artefacts.all(function (err, list) {
      var dup = false, i;
      list = list || [];
      for (i = 0; i < list.length; i++) {
        if (list[i].id !== obj.id) {
          dup = dup || list[i].version === obj.version;
        }
      }
      callback(!dup, 'Wrong version, version number already exists');
    });
  };
Example #11
0
var persist = require('persist')
  , type = persist.type;

var models = {
	Action: persist.define('Action', {
		'tweet_id': type.STRING,
		'screen_name': type.STRING,
		'text': type.STRING
	}),
	Blacklist: persist.define('Blacklist', {
		'screen_name': type.STRING
	})
};

module.exports = models;
Example #12
0
//Daily travel log of drivers.
//Consider the it is update every 30 mins

var persist = require("persist");
var type = persist.type;
var DriverLog = persist.define("driver_travel_log", {
  "id" : {type : type.INTEGER, primaryKey: true},
  "driver_id" : type.INTEGER, //Id of tracked driver
  "area_id": type.INTEGER,//The area that driver and his car is on at this time
  "time": type.DATETIME,//The time block, 30 mins each block (ex: "2014/06/19 9:30", "2014/06/19 10:00")
  "isAvailable" : type.INTEGER // The status of tracked driver in this time block (has passenger or not)
});
DriverLog.DRIVER_STATUS_AVAILABLE = 1;
DriverLog.DRIVER_STATUS_UNAVAILABLE = 0;

module.exports = DriverLog;
var persist = require("persist"),
	type = persist.type;
	Color =require('./color'),
	Estilo=require('./estilo');

module.exports = persist.define("Prenda", {
	"codigo": {type: type.STRING},
	"estilo": {type: type.STRING},
	"color": {type: type.INTEGER},
	"talla": {type: type.STRING},
	"nuevos": {type: type.INTEGER},
	"usados": {type: type.INTEGER},
	"costo_nuevo": {type: type.REAL},
	"costo_usado": {type: type.REAL},
	"costo_renta": {type: type.REAL},
	"funcion": {type: type.INTEGER},
	"borrado": {type:type.BOOLEAN},
	"tipo_prenda": {type: type.INTEGER}
})
.hasOne(Color,{
	name :'color',
	foreignKey : 'color'
})
.hasOne(Estilo,{
	name :'estilo',
	foreignKey : 'estilo'
});
Example #14
0
//Booking request from customer

var persist = require("persist");
var type = persist.type;
var Booking = persist.define("booking", {
  "id" : {type : type.INTEGER, primaryKey : true},
  "area_id" : type.INTEGER, //Id of the area where the booking are placed (send from)
  "time": type.DATETIME,//The moment the booking send by customer
  "driver_id": type.INTEGER,//If has value, the booking has been fullfilled by a driver, 
  //if missed this booking considered MISSED
  "customer_id" : type.INTEGER // Id of customer who placed the booking
});

module.exports = Booking;
Example #15
0
var persist = require("persist");
var DriverLog = require("./driver_log");
var type = persist.type;
var Area = persist.define("area", {
  "id" : {type:type.INTEGER, primaryKey:true},
  "name": type.STRING,//Name/Code of the area (ex: district1_block1, district2_block2)
  "center_longtitute": type.STRING,//The geographic information of the center point of area
  "center_latitute": type.STRING
}).hasMany(DriverLog);

module.exports = Area;
Example #16
0
    it('should create Resource table', function (done) {

    var Resource = persist.define("Resource", {
      'id': type.STRING,
      'owner': type.STRING,
      'path': type.STRING,
      'description': type.STRING,
      'interface': type.STRING,
      'actions': type.STRING,
      'createdDate': { type: type.DATETIME },
      'lastUpdated': { type: type.DATETIME }
      });
//    done();
//    });
//});
//    it('should store new Resource', function (done) {
        var Resource1 = {
            'id': '00000000-0000-0000-0000-000000000000',
            'owner': {'id': '00000000-0000-0000-0000-000000000002'},
            'path': '/courses',
            'description': 'Harvard\'s courses',
            'interface': 'course-catalog',
            'actions': [
            {
              'name': 'read',
              'description': 'read courses'
            },
            {
              'name': 'create',
              'description': 'create courses'
            },
            {
              'name': 'update',
              'description': 'update courses'
            },
            {
              'name': 'delete',
              'description': 'delete courses'
            }
          ]
        };
//        done();
//    });

   persist.connect({
      driver: 'pg',
      db: pg,
      trace: true
    }, function(err, connection) { 
      if(err) 
          console.error('error connecting to pg', err);

      var new_res = new Resource(Resource1);

      new_res.save(connection, function(err, connection) {

      if(err) {
          return console.error('error saving resource', err);
        }
        else     console.log("Successfully connected to database and saved def-resources");
      });
    });
    done();
 });
Example #17
0
var persist = require("persist");
var type = persist.type;

module.exports = State = persist.define("State", {
    "lastUpdated": { type: type.DATETIME },
    "timeToRed": { type: type.INTEGER },
    "title": { type: type.STRING }
})

State.onSave = function (obj, connection, callback) {
    obj.lastUpdated = new Date();
    callback();
}
Example #18
0
File: Taxi.js Project: hsrky/btw
var persist = require("persist"),
    type = persist.type,
    TaxiLocation = require("./TaxiLocation");
    
module.exports = persist.define("taxi", {
    "plate_number": type.STRING,
    "active": type.BOOLEAN      // 0 - inactive, 1 - active
}).hasOne(TaxiLocation);