Permalink
Browse files

first commit

  • Loading branch information...
0 parents commit 314ce953708e2fd336f0b8b90a13828378d93eb4 @mwawrusch mwawrusch committed Nov 24, 2012
Showing with 181 additions and 0 deletions.
  1. +15 −0 .gitignore
  2. +4 −0 .travis.yml
  3. +20 −0 LICENSE
  4. +45 −0 README.md
  5. +25 −0 lib/index.js
  6. +44 −0 package.json
  7. +15 −0 src/index.coffee
  8. +8 −0 test/basic-existenz-test.coffee
  9. +5 −0 test/mocha.opts
15 .gitignore
@@ -0,0 +1,15 @@
+lib-cov
+*.seed
+*.log
+*.csv
+*.dat
+*.out
+*.pid
+*.gz
+
+pids
+logs
+results
+
+node_modules
+npm-debug.log
4 .travis.yml
@@ -0,0 +1,4 @@
+language: node_js
+node_js:
+ - 0.8
+ - 0.9
20 LICENSE
@@ -0,0 +1,20 @@
+Copyright (c) 2012 Martin Wawrusch
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
45 README.md
@@ -0,0 +1,45 @@
+mongoose-plugins-timestamp
+===========================
+
+npm install mongoose-plugins-timestamp
+
+A simple timestamp plugin for mongoose.
+
+pluginTimestamp = require "mongoose-plugins-timestamp"
+YourSchema.plugin pluginTimestamp.timestamps
+
+
+## Release Notes
+
+### 0.2.0
+* First version
+
+## Internal Stuff
+
+* npm run-script watch
+
+## Publish new version
+
+* Change version in package.json
+git add . -A
+git commit -m "Upgrading to v0.2.0"
+git tag -a v0.2.0 -m 'version 0.2.0'
+git push --tags
+npm publish
+
+## Contributing to mongoose-plugins-timestamp
+
+* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
+* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
+* Fork the project
+* Start a feature/bugfix branch
+* Commit and push until you are happy with your contribution
+* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
+* Please try not to mess with the package.json, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
+
+## Copyright
+
+Copyright (c) 2012 Martin Wawrusch See LICENSE for
+further details.
+
+
25 lib/index.js
@@ -0,0 +1,25 @@
+// Generated by CoffeeScript 1.4.0
+(function() {
+ var mongoose;
+
+ mongoose = require("mongoose");
+
+ exports.timestamps = function(schema, options) {
+ if (!options) {
+ options = {};
+ }
+ schema.add({
+ createdAt: Date,
+ updatedAt: Date
+ });
+ return schema.pre("save", function(next) {
+ if (!this.createdAt) {
+ this.createdAt = this.updatedAt = new Date;
+ } else {
+ this.updatedAt = new Date;
+ }
+ return next();
+ });
+ };
+
+}).call(this);
44 package.json
@@ -0,0 +1,44 @@
+{
+ "author": "Martin Wawrusch <martin@wawrusch.com> (http://martinatsunset.com)",
+ "name": "mongoose-plugins-timestamp",
+ "description": "Some error objects prepackaged.",
+ "version": "0.2.0",
+ "main" : "lib/index.js",
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/codedoctor/mongoose-plugins-timestamp.git"
+ },
+ "bin" : {
+ },
+ "directories" : {
+ "lib" : "./lib",
+ "test" : "./test"
+ },
+ "keywords" : [
+ "errors"
+ ],
+ "scripts": {
+ "prepublish" : "coffee -c -o lib src",
+ "watch" : "coffee -c -w -o lib src",
+ "test": "coffee -c -o lib src;NODE_ENV=test node_modules/.bin/mocha --timeout 10000 -R spec test/*.coffee"
+ },
+ "engines": {
+ "node": ">=0.8.0"
+ },
+ "dependencies": {
+ "mongoose" : ">=3.4.0"
+ },
+ "devDependencies": {
+ "async": "0.1.22",
+ "coffee-script": "1.4.0",
+ "should": "1.2.1",
+ "mocha": "1.6.0"
+ },
+ "bugs": { "url": "http://github.com/codedoctor/mongoose-plugins-timestamp/issues" },
+ "licenses": [
+ { "type": "MIT",
+ "url": "http://github.com/codedoctor/mongoose-plugins-timestamp/raw/master/LICENSE"
+ }
+ ]
+
+}
15 src/index.coffee
@@ -0,0 +1,15 @@
+mongoose = require("mongoose")
+
+exports.timestamps = (schema, options) ->
+ options = {} unless options
+
+ schema.add
+ createdAt: Date
+ updatedAt: Date
+
+ schema.pre "save", (next) ->
+ unless @createdAt
+ @createdAt = @updatedAt = new Date
+ else
+ @updatedAt = new Date
+ next()
8 test/basic-existenz-test.coffee
@@ -0,0 +1,8 @@
+assert = require 'assert'
+should = require 'should'
+
+describe 'WHEN loading the module', ->
+ index = require '../lib/index'
+
+ it 'should exist', ->
+ should.exist index
5 test/mocha.opts
@@ -0,0 +1,5 @@
+--require assert
+--require should
+--globals name
+--compilers coffee:coffee-script
+--timeout 10s

0 comments on commit 314ce95

Please sign in to comment.