Giter VIP home page Giter VIP logo

docpad-plugin-mongo's Introduction

MongoDB plugin

Add to docpad.coffee

# Define the DocPad Configuration
docpadConfig = {

	[...]

	plugins:

		mongo:
			hostname: 'mongodb://...:[email protected]:10044/'
			# hostname: 'mongodb://localhost/'
			user: ...
			pass: ...
			database: 'app22118608'		
			collection: 'gigs',
			customSchema:
				town: String,
				date: { type: Date, default: Date.now },
				location: String,
				link: String		
			queryArr: [
				name: "futuregigs"
				predicate: {"date": {$gte: new Date()}}
			,
				name: "pastgigs"
				predicate: {"date": {$lt: new Date()}}
			]
}

# Export the DocPad Configuration
module.exports = docpadConfig

Example of usage in eco file, note the extra hidden input element that tells the server which predicate to use to rewrite all the content of (it will delete everything matching the predicate first and then insert the data sent from the client).

<% zero_pad = (x) -> if x < 10 then '0'+x else ''+x %>
<input type='hidden' id='queryName' value='futuregigs'>
<% if @gigs.length: %>
	<% for gig in @futuregigs: %>
		<% mString = gig.date.getFullYear() %>
		<% mString += "-"+ zero_pad (gig.date.getMonth() + 1) %>
		<% mString += "-"+ zero_pad gig.date.getDate() %>
		<div class="gig-entry">
			<input type="hidden" name="_id" value="<%= gig._id %>">
			<input type="date" name="date" width="20" value="<%- mString %>">
			<input type="textarea" name="location" value="<%= gig.location %>">
			<input type="textarea" name="town" value="<%= gig.town %>">
			<input type="textarea" name="link" value="<%= gig.link %>">
		</div>
	<% end %>
<% end %>

docpad-plugin-mongo's People

Contributors

simonh1000 avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

nfriedly

docpad-plugin-mongo's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.