Permalink
Browse files

Updated index definition

  • Loading branch information...
wjohnald committed Oct 1, 2012
1 parent f021a3c commit cb54581d62f78e2248d5252c817449fb561061a0
Showing with 37 additions and 33 deletions.
  1. +37 −33 README.md
View
@@ -43,54 +43,58 @@ Example
]
});
- var db = mongoose.createConnection('localhost', 'sluggabledemo');
-
+ var db = mongoose.createConnection('localhost', 'sluggabledemoseven');
db.once('open', function() {
var ClimbingRoute = sluggableSchema.model(db);
- var routeOne = new ClimbingRoute({
- name: "High Exposure",
- location: "Gunks",
- partner: "Bob"
- });
- var routeTwo = new ClimbingRoute({
- location: "Gunks",
- name: "High Exposure",
- partner: "Dylan"
- });
+ ClimbingRoute.once('index', function() {
+
+ var routeOne = new ClimbingRoute({
+ name: "High Exposure",
+ location: "Gunks",
+ partner: "Bob"
+ });
+ var routeTwo = new ClimbingRoute({
+ location: "Gunks",
+ name: "High Exposure",
+ partner: "Dylan"
+ });
- routeOne.save(function(err) {
- console.log("Route One: " + routeOne.slug + " with " + routeOne.partner);
+ routeOne.save(function(err) {
+ console.log("Route One: " + routeOne.slug + " with " + routeOne.partner);
- // Save route 2 after we know route 1 has been saved
- routeTwo.save(function(err) {
- console.log("Route Two: " + routeTwo.slug + " with " + routeTwo.partner);
+ // Save route 2 after we know route 1 has been saved
+ routeTwo.save(function(err) {
+ console.log("Route Two: " + routeTwo.slug + " with " + routeTwo.partner);
+ });
});
- });
- var routeThree = new ClimbingRoute({
- name: "High Exposure",
- location: "Gunks",
- partner: "Patrick"
- });
- var routeFour = new ClimbingRoute({
- location: "Gunks",
- name: "High Exposure",
- partner: "Stewart"
- });
+ var routeThree = new ClimbingRoute({
+ name: "High Exposure",
+ location: "Gunks",
+ partner: "Patrick"
+ });
+ var routeFour = new ClimbingRoute({
+ location: "Gunks",
+ name: "High Exposure",
+ partner: "Stewart"
+ });
- routeThree.save(function(err) {
- console.log("Route Three: " + routeThree.slug + " with " + routeThree.partner);
- });
- routeFour.save(function(err) {
- console.log("Route Four: " + routeFour.slug + " with " + routeFour.partner);
+ routeThree.save(function(err) {
+ console.log("Route Three: " + routeThree.slug + " with " + routeThree.partner);
+ });
+ routeFour.save(function(err) {
+ console.log("Route Four: " + routeFour.slug + " with " + routeFour.partner);
+ });
});
+ // The only gaurantee is that once will be saved before two.
});
+
Dependencies
============

0 comments on commit cb54581

Please sign in to comment.