grantjbutler / fetchr

A command line utility for interacting with a Core Data store using JavaScript.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

fetchr

fetchr is a command line utility that allows for querying a Core Data store using a JavaScript API.

Status

fetchr is in a basic usable state. You can create a fetch request, assign an entity to it, assign a predicate, set sort descriptors, set relationship paths for prefetching, and then execute it to get results. Things that still need to be implemented include setting a fetch limit, setting which properties to fetch, and setting properties to group by.

API

Predicate

Class Methods

Predicate.format

Creates a predicate with the specified format. The method mirrors +[NSPredicate predicateWithFormat:] See Predicate Format String Syntax for more details.

var sign = isAdult ? '>=' : '<';
Predicate.format('%K %@ 18', 'age', sign);

SortDescriptor

Constructor

The constructor mirrors the initializer for NSSortDescriptor. It takes two arguments, the name of the key to sort by, and whether the sort should be ascending (true) or descending (false).

var sortDescriptor = new SortDescriptor('name', true);

FetchRequest

Properties

entityName

The name of the entity as defined in the managed object model.

var request = new FetchRequest();
request.entityName = 'Person';
predicate

A Predicate instance for filtering objects from a Core Data store.

var request = new FetchRequest();
request.entityName = 'Person';
request.predicate = Predicate.format('%K >= 18', 'age');
sortDescriptors

An array of SortDescriptor instances to sort the fetch request by.

var request = new FetchRequest();
request.entityName = 'Person';
request.sortDescriptors = [new SortDescriptor('name', true)];
relationshipKeyPathsForPrefetching

An array of strings that are key paths of relationships to fetch.

var request = new FetchRequest();
request.entityName = 'Person';
request.predicate = Predicate.format('%K.@count >= 3', 'relatives');
request.relationshipKeyPathsForPrefetching = ['relatives'];

fetchr

Methods

executeFetchRequest

Executes a FetchRequest against a Core Data store, and returns the results, if any.

var request = new FetchRequest();
request.entityName = 'Person';
request.predicate = Predicate.format('%K >= 18', 'age');
var results = fetchr.executeFetchRequest(request);

About

A command line utility for interacting with a Core Data store using JavaScript.


Languages

Language:Objective-C 77.1%Language:Mathematica 22.9%