npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

beetle.js

v3.0.8

Published

Beetle is a data manager for Javascript. The goal is to be able to work with data as easy as Entity Framework and LINQ.

Downloads

69

Readme

Beetle.js

Build status NuGet Badge npm version Join the chat at https://gitter.im/umutozel/Beetle.js

Beetle is a data manager for Javascript. The goal is to be able to work with data as easy as Entity Framework and LINQ.

Features

  • Tracks objects and persists changes to server
  • Can work with Knockout and ES5 properties (others can be implemented easily)
  • Can work with Q, Angular, ES6 and jQuery promises
  • Supports data model inheritance
  • Supports aggregate functions
  • Can work without metadata
  • Can work with Mvc and WebApi Controllers
  • Supports property, entity validations
  • Can use existing data annotation validations (carries multi-language resource messages to client)
  • Can query server with Http POST
  • Can be extended to support almost every library (client and server side), flexible architecture
  • Auto fix navigation properties (after foreign key set, entity attach etc..)
  • Can check-auto convert values for its proper data types
  • Can be internationalized (for internal messages, validation messages etc..)

Current prerequisities

All dependencies have base types so custom implementations can be made easily.

  • Entity Framework
  • WebApi or Asp.Net Mvc project for service
  • Knockout.js or EcmaScript5 Properties for providing observable properties

Usage

  • Create a Controller and inherit from BeetleApiController, generic argument tells we are using Entity Framework context handler with TestEntities context (DbContext)
public class BeetleTestController : BeetleApiController<EFContextHandler<TestEntities>> {
		
	[HttpGet]
	public IQueryable<Entity> Entities() {
		return ContextHandler.Context.Entities;
	}
}
  • Configure routing
public static class BeetleWebApiConfig {

	public static void RegisterBeetlePreStart() {
		GlobalConfiguration.Configuration.Routes.MapHttpRoute("BeetleApi", "api/{controller}/{action}");
	}
}
  • Create an entity manager
var manager = new EntityManager('api/BeetleTest');
  • Create a query
var query = manager.createQuery('Entities').where('e => e.Name != null');
  • Execute the query and edit the data
manager.executeQuery(query)
	.then(function (data) {
		self.entities = data;
        data[0].UserNameCreate = 'Test Name';
    })
  • Execute local query
var hasCanceled = self.entities.asQueryable().any('e => e.IsCanceled == true').execute();
// q is shortcut for asQueryable, x is shortcut for execute
var hasDeleted = self.entities.q().any('e => e.IsDeleted').x();
// alias is optional
var hasDeleted = self.entities.q().any('IsDeleted').x();

// with beetle.queryExtensions.js we can write queries like these;
// this query will be executed immediately and returns true or false
var hasExpired = self.entities.any('IsExpired == true');
// below query will be executed after it's length property is accessed (like LINQ GetEnumerator)
var news = self.entities.where('IsNew');
  • Add a new entity
var net = manager.createEntity('EntityType', {Id: beetle.helper.createGuid()});
net.Name = 'Test EntityType';
  • Delete an entity
manager.deleteEntity(net);
  • Save all changes
manager.saveChanges()
    .then(function () {
        alert('Save succesfull');
    })

Supported Data Types

string, guid, date, dateTimeOffset, time, boolean, int, number (for float, decimal, etc..), byte, enum, binary, geometry, geography (spatial types are supported partially, can be fully supported once we decide how to represent them at client side)

Validators

required, stringLength, maximumLength, minimumLength, range, emailAddress, creditCard, url, phone, postalCode, time, regularExpression, compare

Supported Query Expressions

ofType, where, orderBy, expand (include), select, skip, top (take), groupBy, distinct, reverse, selectMany, skipWhile, takeWhile, all, any, avg, max, min, sum, count, first, firstOrDefault, single, singleOrDefault, last, lastOrDefault

Supported Query Functions

toupper, tolower, substring, substringof, length, trim, concat, replace, startswith, endswith, indexof, round, ceiling, floor, second, minute, hour, day, month, year, max, min, sum, count, avg, any, all, contains (can be used in expression strings, some are not supported by OData but can be used with beetle query string format)

License

See License

Thanks to JetBrains for providing us with free licenses to their great tools.