Joe Gornick

Web Geekology

MongoDB Unique Indexes on Single/Embedded Documents

MongoDB doesn’t support unique indexes on embedded documents in the same document. However, it does support some scenarios for adding unique indexes on embedded documents. When you apply a unique index to an embedded document, MongoDB treats it as unique in the collection. The following is an example of setting up a unique index on an embedded document:

Setting Up Multiple Browsers on Mac OS X

When doing web development, you need to test your work on many operating systems and browsers. Depending on your host operating system, you will also need to run virtual machines to test other operating systems and browsers. For this article, we are focusing on setting up different browsers/version on OS X (10.6 - Snow Leopard).

For Mac, the most common browsers are Safari, Firefox, Opera and recently Chrome. On my machine, I have setup the following browsers and versions:

  • Safari: 2.04, 3.04, 3.12, 3.21, 4.04
  • Firefox:, 3.0.17, 3.5.7
  • Opera: 9.52, 9.64, 10.01, 10.10
  • Chrome: (Latest)

MySQL: Created & Modified Date Fields

I’ve been searching for an efficient way to set created and modified date fields in MySQL. Of course, this can be done in the application you’re writing, however, I wanted to find a way to automatically do this on the database layer.

Please note, this approach is targeted for MySQL 5.0+.

The approach I take here is a combination of using the TIMESTAMP field data type and a TRIGGER.