January 17th, 2012 › Development › richard › no comments ›
Got this error trying to update a field in a mongodb collection. Turns out I was previously using the same field to store object Ids. Now that I’m trying to repurpose the field to store a different datatype, mongo throws an error. Solution was to remove the old field completely from all documents within the collection using the unset command. With no documents having this field, mongo was able to append the new field with the new data type.
May 15th, 2011 › Development › richard › no comments ›
Things change quickly in the world of node development, you’re usually working with a lot of different modules within your projects. Fortunately there’s a great package manager that most node developers used called NPM. It makes installing and updating dependencies in your environment fairly simple. At anytime you can see a list of installed packages and their version number using:
npm ls installed
Tags: nodejs, npm
May 15th, 2011 › Development › richard › 1 comment ›
The docs on MongooseJS can be really unclear at times, here are some pointers on validation that may help (note this is valid as of MongooseJS 1.3.3)
Making a field unique:
var User = new Schema({
email: { index: {unique: true} }
});
Note: If your collection exists in Mongo, you need to drop the collection before schema changes kick in. Otherwise, you’ll see duplicated fields and wonder why it doesn’t work. If all is working, when you call User.save(), Mongoose will throw an error such as – ‘E11000 duplicate key error index: …’ if the field is duplicated.
Validating a schema field:
When defining a field you can do some basic validation through Mongoose, such as indicating a max or min for numbers, specifying the field is required, or matching to a regular expression. For more advanced validation you can provide a call to function which is evaluated after any defaults for a field is applied. In almost all instances, validating through a function seems to be the most robust approach, even for checking a required field, regex, or max/min values. Assuming you already defined a validation function for your schema field, you can associate it two ways,
var User = new Schema({
email: { index: { unique: true }, validate: [ isValidEmail, 'Please provide a valid email' }
});
or
User.path('email').validate( isValidEmail(value), 'Please provide a valid email' );
Validating a virtual schema field:
If you are using virtuals within a schema, it would be nice to validate them from the model. There are a couple approaches that won’t work. Chaining a .validate function onto a virtual schema field definition, throws a compiler error when launching node. Likewise, attempting to attach a .validate function using Schema.path() will also fail as virtuals are not accessible using path(). The best solution is to use middleware from within the model to validate the virtual attribute.
User.pre('save', function (next) {
if (this.virtualfield) {
next ( new Error('This field is required.') );
} else {
next ();
}
});
Tags: mongoose, nodejs
March 24th, 2011 › Uncategorized › richard › no comments ›
SharePoint is built on ASP.NET technology. Applications hosted through IIS, (like an ASP.NET website or SharePoint) must initially be compiled before being sent to the user. This is a process called Just-In-Time compilation. Application Pools within IIS are responsible for execution of applications (like SharePoint) they manage resources like memory, and invoke JIT compilation, as well as other services like caching. Applications Pools will naturally shut down if left idle as to free up resources no longer needed. Application Pools will also occasionally recycle or restart if memory thresholds are reached. In these cases, the Application Pool must initiate JIT compilation of hosted applications as well as begin allocating resources when a request for the application is received again. The user requesting the application for the first time will experience a delay while the Application Pool compiles the site and makes it available for servicing. Subsequent requests for the application do not occur this overhead. To prevent users from ever experiencing this delay, warm up jobs or scripts are created to request sites running on an IIS server periodically or before demand is expected. The initial delay in startup of an application pool still occurs, but the experience of a delay now occurs in a command prompt running as a scheduled task, not a user’s browser.
March 23rd, 2011 › Uncategorized › richard › no comments ›
Document co-authoring is a new feature within SharePoint 2010 and Microsoft Office Word, OneNote and PowerPoint 2010. When multiple users edit a document on a SharePoint site, changes saved back while editing are available to other users also editing the document.
This functionality can be disabled by checking out the document before editing. Users can individually check out documents as a way to lock them, so other users cannot co-author with them. Co-authoring requires that check-out not be required on any document library used for co-authoring documents. Requiring check-out in a document library is one way to disable co-authoring for the whole library. Co-authoring functionality can also be disabled on the client side using Group Policy.
March 10th, 2011 › SharePoint › richard › no comments ›
It’s not always clear how licensing works with Microsoft, even when you visit the product page and compare editions for SharePoint 2010 you’re still left with scratching your head. To help, here’s a bullet list of things to keep in mind -
- SharePoint 2010 Foundation (previously known as WSS 3.0) comes included with Windows 2008 Server Standard edition. You need Windows Server CALs for user access.
- SharePoint 2010 Server is a server product that you install on-top of Windows 2008 Server and is licensed separately per server. You may see “Standard” or “Enterprise” but the server product comes in only one version and has only one SKU.
- Standard & Enterprise CALs (client access licenses). Each user connecting to a SharePoint server needs a standard CAL. For users accessing enterprise features, they also need an enterprise CAL. Note – its not one or the other, but both (Standard with Enterprise CALs) if you decide to use any of the enterprise features.
- Summary of Enterprise CAL features -
- FAST Search Centers
- Sorting by any managed property
- Contextual search results (i.e. user or audience targeted)
- Refinement filter counts
- Similar results
- Thumbnails and previews
- Visual best bets
- Scale and other search platform enhancements
- Business Intelligence
- KPI’s
- Chart Web Parts
- Dashboards
- Data Connection Library
- PowerPivot for SharePoint
- Access Services
- Excel Services
- InfoPath Services
- Visio Services
- PerformancePoint Services
- Microsoft FAST Search Server for SharePoint – if using FAST Search Centers as part of the Enterprise CAL, you need a separate server license for each FAST server that will actually index and crawl content. Vice versa, if you want to implement Microsoft FAST Search – you need Enterprise CALs to access the search centers within SharePoint 2010.
Note, the above covers mostly intranet/extranet scenarios. Microsoft have specific versions of SharePoint 2010 for Internet sites that may also require Window External Connector licenses for your Windows 2008 servers, these versions also have Standard and Enterprise features and can be used with Microsoft FAST Search.
In addition to the above, the following links are also great resources for understanding SharePoint 2010 licensing
October 27th, 2010 › Development, SharePoint › richard › no comments ›
Need to deploy a WSP to a new SharePoint 2007 server but don’t have an archive of it? The following utility allows you to extract a specific or all WSPs packages installed on a SharePoint farm and save them to disk where you can redeploy it to another server. Very useful -
http://code.msdn.microsoft.com/SPSolutionExtractor
Be wary though – the author of this tool doesn’t seem familar with command line tools. Not only is the executable’s name far too wordy, certain menus and prompts seem to lack polish, however it does get the job done.
June 15th, 2010 › Development, SharePoint › richard › no comments ›
If you’re doing SharePoint development then you’ve no doubt heard of the GAC, or Global Assembly Cache (c:\windows\assembly) where compiled assemblies are deployed. In a SharePoint farm with several front-ends, you may occasionally find a server with a missing DLL or the wrong version of the assembly.
The following tool makes quick work of trying to find differences in the GAC for remote servers and evens offers up a nifty HTML report. Very nicely done.
http://gaccompare.codeplex.com/
A couple things – you need to have Admin rights on the remote computers, the tool does take a while to do the compare (so be patient) and to get the HTML report and other cool features, right-click in the results pane after it has loaded.
June 10th, 2010 › Development, IIS › richard › no comments ›
If you noticed your website is running slow, probably one of the first things you do is log into your web server, open Task Manager and check what’s going on. Usually you will see a process called w3wp.exe (or several instances of it) running and using high cpu utilization.
W3wp.exe is the worker process that Internet Information Services (IIS) uses for the application pools on your site. Each application pool, is assigned a separate worker process. That way an exception or crash in one of your application pools doesn’t affect other sites running in a different app pool.
To identify which w3wp process belongs to which application pool, here is what you will need to do. NOTE: this is specific for IIS 7.
In Task Manager, switch to the Processes tab. From the top menu, click on View and then Select Columns…, ensure that PID (Process Identifier) is checked.
Now open a command window (Start -> Run -> cmd.exe) and change directory to the following path,
cd c:\windows\system32\inetsrv
*notice that inetsrv may be inetsrv32 or inetsrv64 depending on your specific version of Windows Server.
Once in this directory, type the following:
appcmd list wp
The output will appear with the Process ID (PID from Task Manager) and the associated application pool belonging to it.
Another helpful command is: appcmd list requests
This will list all current requests and other useful information, such as time in milliseconds to help you identify long running requests.
June 10th, 2010 › Development, IIS › richard › 3 comments ›
In my last post, I mentioned the Internet Information Services (IIS) Manager feature called Worker Processes, and explained how you can use it to glean information into high cpu utilization for the w3wp.exe process(es) running on your server. If you followed the steps and got the following error: “There was an error while performing this operation. Details: Category does not exist.” Here is what you can do to resolve the issue.
The issue stems from the performance counters on the server being disabled. To verify – run the following at the command line,
lodctr /q:PerfProc
If you see the following,
[PerfProc] Performance Counters (Disabled)
The performance counters are not running. To activate them, run the following command,
lodctr /e:PerfProc
Once done, close any instances of the IIS Manager that you had open. Reopen IIS Manager, and you should now see the Worker Processes feature.
Thanks to the following for information about this issue:
http://bit.ly/b9yhrV