Tutorial by Examples: field

Provides the number of columns or fields in each record (record corresponds to each line). Each line is demarcated by RS which defaults to newline. cat > file1 Harley Quinn Loves Joker Batman Loves Wonder Woman Superman is not dead Why is everything I type four fielded!? awk '{print NF}' ...
Examples of numeric fields are given: AutoField An auto-incrementing integer generally used for primary keys. from django.db import models class MyModel(models.Model): pk = models.AutoField() Each model gets a primary key field (called id) by default. Therefore, it is not necessary t...
This is a specialized field, used to store binary data. It only accepts bytes. Data is base64 serialized upon storage. As this is storing binary data, this field cannot be used in a filter. from django.db import models class MyModel(models.Model): my_binary_data = models.BinaryField() ...
@Entity class Note { @Id Integer id; @Basic String note; @Transient String parsedNote; String readParsedNote() { if (parsedNote == null) { /* initialize from note */ } return parsedNote; } } If your class needs fields that should ...
perl -lane'print "$F[0] $F[-1]"' data.txt # prints the first and the last fields of a space delimited record CSV example: perl -F, -lane'print "$F[0] $F[-1]"' data.csv
db.posts.find().forEach(function(doc){ db.posts.update({_id: doc._id}, {$set:{'version':'v1.0'}}, false, true); });
With the power of regex comes great responsibility.... db.posts.find({'text': /.*foo.*|.*bar.*/i})
db.posts.find().forEach(function(doc){ if(doc.oldField){ db.posts.update({_id: doc._id}, {$set:{'newField':doc.oldField}}, false, true); } });
db.posts.find().forEach(function(doc){ if(doc.commenters){ var firstCommenter = db.users.findOne({'_id': doc.commenters[0]._id }); db.clients.update({_id: doc._id}, {$set:{'firstPost': firstCommenter }}, false, true); var firstCommenter = db.users.findOne({'_id': do...
db.posts.find().forEach(function(doc){ if(!doc.foo){ db.posts.update({_id: doc._id}, {$set:{'foo':''}}, 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); } });
db.posts.find().forEach(function(doc){ if(doc.oldfield){ // the false, true at the end refers to $upsert, and $multi, respectively db.accounts.update({_id: doc._id}, {$unset: {'oldfield': "" }}, false, true); } });
var newvalue = ""; db.posts.find().forEach(function(doc){ if(doc.foo){ newvalue = '"' + doc.foo + '"'; db.accounts.update({_id: doc._id}, {$set: {'doc.foo': newvalue}}); } });
var newvalue = null; db.posts.find().forEach(function(doc){ if(doc.foo){ newvalue = '"' + doc.foo + '"'; db.accounts.update({_id: doc._id}, {$set: {'doc.foo': newvalue}}); } });
db.posts.find().forEach(function(doc){ if(doc._id){ db.posts.update({_id: doc._id}, {$set:{ timestamp: new Date(parseInt(doc._id.str.slice(0,8), 16) *1000) }}, false, true); } });
Two important things to note when adding fields to a Pivot Table are Orientation and Position. Sometimes a developer may assume where a field is placed, so it's always clearer to explicitly define these parameters. These actions only affect the given Pivot Table, not the Pivot Cache. Dim thisPivot ...
class MyDataObject extends DataObject { private static $db = array( 'Name' => 'Varchar' ); private static $has_one = array( 'OtherDataObject' => 'OtherDataObject' ); private static $summary_fields = array( 'Name', 'OtherDat...
class MyDataObject extends DataObject { ... private static $has_many = array( 'OtherDataObjects' => 'OtherDataObject' ); function getCMSFields() { $fields = parent::getCMSFields(); if ($gridField = $fields->dataFieldByName('OtherDataObject...

Page 4 of 11