| <?php | |
| class iCal | |
| { | |
| /** | |
| * @var string | |
| */ | |
| public $title; |
I've developed a useful feature in KeystoneJS that lets you populate a relationship from either side, while only storing the data on one side, and am looking for feedback on whether it is something that could / should be brought back into mongoose itself. (It might be possible to add as a separate package but I suspect there'd be too much rewriting of mongoose internals for that to be a good idea).
I've added this as an issue in mongoose for consideration: #1888 but am leaving this gist in place because the examples are easier to read.
I've used Posts and Categories as a basic, contrived example to demonstrate what I'm talking about here; in reality you'd rarely load all the posts for a category but there are other real world cases where it's less unreasonable you'd want to do this, and Posts + Categories is an easy way to demo it.
The built-in population feature is really useful; not just for
| /* | |
| * WARNING: This code uses ECMAScript 6 features. | |
| * today June 20, 2013, this works in Chrome only | |
| * if you enable Javascript Experiments in your | |
| * chrome flags settings. | |
| */ | |
| /* | |
| * This is not a full implementation of the presented/idea | |
| * Component Carcass |
| /* | |
| * Vanilla JS - Touch Gestures | |
| * @version 0.1 | |
| * @inspired QuoJS - http://quojs.tapquo.com | |
| * | |
| * Supported Gestures: singleTap, doubleTap, hold, | |
| * swipe, swiping, swipeLeft, swipeRight, swipeUp, swipeDown, | |
| * rotate, rotating, rotateLeft, rotateRight, pinch, pinching, | |
| * pinchIn, pinchOut, | |
| * drag, dragLeft, dragRight, dragUp, dragDown |
| /** | |
| Problem: | |
| You have a javascript array that likely has some duplicate values and you would like a count of those values. | |
| Solution: | |
| Try this schnippet out. | |
| */ |
| <?php /* | |
| * This is just a simple loop to display 7 attachments attached to a post or page in WordPress | |
| * You can change 'medium' and 'thumbnail' to add sizes you have definied in your theme by the add_image_size function | |
| * in WordPress | |
| */ | |
| ?> | |
| <div id="thumbs" class="pic_list"> | |
| <ul class="thumbs"> | |
| <?php /* Time to create a new loop that pulls out the first 7 image attachments for this post */ | |
| $args = array( 'post_type' => 'attachment', 'numberposts' => 7, 'post_status' => null, 'post_parent' => $post->ID ); |

