Skip to content

Instantly share code, notes, and snippets.

View omanizer's full-sized avatar

Ben Oman omanizer

View GitHub Profile
<?php
/*
* This is an update to this file to make it compatible with PHP's new MongoDB driver. This file depends
* on many aspects of the old Mongo driver (such as the MongoId and MongoDate classes) that don't exist
* in the new MongoDB driver
*/
/*
/*
JS-Data clear out all collection data and any cached queries so that findAll will hit the server again the first time.
The app I'm working on allows the user to switch contexts where the data in one context is different than the data in another.
This functions similar to having multiple Google accounts where the schema for an email is the same but a different Gmail mailbox is shown.
Being that I have dozens of resource types I needed a quick way to remove all records from each collection and also clear out any saved
requests so that Store.findAll() will hit the server again with the context being different.
Below clears out all collection data and any flags that a request has been cached.
*/
// My resource instance editor
import Store from 'src/datastore'
// CURRENTLY DOING THIS
onOpen: function (_id) {
scope.myResource = Store.createRecord('myresource', {new: true})
if (_id) {
Store.find('myresource', _id, {force:true}).then(function (resource) {
@omanizer
omanizer / mongo-strict-to-shell.php
Last active August 29, 2015 14:25
Convert Strict JSON $oid and $date values to MongoDB Shell equivalent values
<?php
/*
This method recursively converts all ObjectId and Date strict json mode values to MongoDB BSON Shell values.
$arr should be a MongoDB query in Strict JSON mode (it will contain something like {"_id":{"$oid":"deadbeefdeadbeefdeadbeef"}} instead of {"_id":ObjectId("deadbeefdeadbeefdeadbeef")}.
Example Input:
{
"$and": [