Tutorial by Examples: v

Type abbreviations allow you to create aliases on existing types to give them a more meaningful senses. // Name is an alias for a string type Name = string // PhoneNumber is an alias for a string type PhoneNumber = string Then you can use the alias just as any other type: // Create a recor...
@Entity class Note { @Id Integer id; @Basic String note; @Basic int count; } Getters, setters etc. are ommitted for brevity, but they are not needed for JPA anyway. This Java class would map to the following table (depending on your database, here given in on...
SELECT x, ... FROM ( SELECT y, ... FROM ... ) AS a JOIN tbl ON tbl.x = a.y WHERE ... This will evaluate the subquery into a temp table, then JOIN that to tbl. Prior to 5.6, there could not be an index on the temp table. So, this was potentially very inefficient: SELECT ... ...
TRUNCATE tableName; This will delete all the data and reset AUTO_INCREMENT index. It's much faster than DELETE FROM tableName on a huge dataset. It can be very useful during development/testing. When you truncate a table SQL server doesn't delete the data, it drops the table and recreates it, th...
With a column of one of the string types, named my_date_field with a value such as [the string] 07/25/2016, the following statement demonstrates the use of the STR_TO_DATE function: SELECT STR_TO_DATE(my_date_field, '%m/%d/%Y') FROM my_table; You could use this function as part of WHERE clause a...
It is good practice to test the calling program's __name__ variable before executing your code. import sys def main(): # Your code starts here # Don't forget to provide a return code return 0 if __name__ == "__main__": sys.exit(main()) Using this pattern ens...
Margin is one of a few CSS properties that can be set to negative values. This property can be used to overlap elements without absolute positioning. div{ display: inline; } #over{ margin-left: -20px; } <div>Base div</div> <div id="over">Overlapping div&lt...
curl -XGET 'http://www.example.com:9200/myIndexName/myTypeName/1' Output: { "_index" : "myIndexName", "_type" : "myTypeName", "_id" : "1", "_version" : 1, "found": true, "_source&qu...
Let's say there's a collection called Todos and the autopublish package is added. Here is the basic component. import { createContainer } from 'meteor/react-meteor-data'; import React, { Component, PropTypes } from 'react'; import Todos from '/imports/collections/Todos'; export class List exte...
If your application is going to run on different devices, it's going to need to render to different ViewPorts, based on the device size. You can deal with this in two ways: with javascript rules, or CSS media styles. If you've been using a MVC or MVVM library, such as Angular or Ember (or Blaze, for...
Now it's time to go through the Meteor Cordova Phonegap Integration documentation. Since that documentation was written, XCode and Yosemite have been released, which has caused some hiccups in installation. Here are the steps we had to go through to get Meteor compiled to an iOS device. Upgrade ...
Register your Apple Developer Account Register an App ID for your app Register the UUID of your testing devices Generate an iOS App Development provisioning profile Generate a CertificateSigningRequest from KeychainAccess Submit CertificateSigningRequest to https://developer.apple.com/accou...
Make sure your development workstation and iPhone are connected to the same WiFi network. Tethering, hotspots, and other ad-hoc networking won't work. Run sudo meteor run ios-device Deploy to your device!
This command will create a /dump directory, and store each collection in a separate BSON blob file. This is the best way to backup or transfer databases between systems. mongodump --db meteor
db.posts.find().forEach(function(doc){ db.posts.update({_id: doc._id}, {$set:{'version':'v1.0'}}, false, true); });
db.posts.find().forEach(function(doc){ if(doc.arrayOfObjects){ // the false, true at the end refers to $upsert, and $multi, respectively db.accounts.update({_id: doc._id}, {$unset: {'arrayOfObjects': "" }}, false, true); } });
db.posts.find().forEach(function(doc){ if(doc.commentsBlobId){ var commentsBlob = db.comments.findOne({'_id': commentsBlobId }); db.posts.update({_id: doc._id}, {$set:{'comments': commentsBlob }}, false, true); } });
db.posts.find().forEach(function(doc){ if(!doc.foo){ db.posts.update({_id: doc._id}, {$set:{'foo':'bar'}}, false, true); } });
db.posts.find().forEach(function(doc){ if(doc.foo === 'bar'){ db.posts.remove({_id: doc._id}); } });
db.posts.find().forEach(function(doc){ if(doc.foo === 'bar'){ db.posts.update({_id: doc._id}, {$set:{'foo':'squee'}}, false, true); } });

Page 103 of 296