How-to Build CRUD Enabled iOS Apps with the LoopBack API Server – Part 1

In this two-part tutorial we’ll be creating an iOS app that connects to a LoopBack API server to perform create, read, update, and delete (CRUD) operations. In Part One we’ll show you how to fetch data stored in an in-memory data source. Part Two will explain how to connect various interface elements to the iOS app.

Prerequisites

Before starting this tutorial:

Read more

How-to Build CRUD Enabled iOS Apps with the LoopBack API Server – Part 2

Welcome to the second installment of a two-part tutorial on how to create an iOS app that connects to a LoopBack API server application to perform create, read, update, and delete (CRUD) operations. In Part One we looked at how to fetch data. In this blog we’ll look at how to connect the various interface elements to the iOS app.

Add navigation control

To add a navigation control to your app:

  1. Select Books Collection View Controller.
  2. Click Editor > Embed In > Navigation Controller. This will add a Navigation Item under the Books Collection View Controller, as shown below.
  3. Select the new Navigation Item and name it “Books Collection” in the attribute inspector.

navigation
Read more

Defining and Mapping Data Relations with LoopBack Connected Models

In LoopBack, working with data is usually the core of business logic. We typically start by defining models to represent business data. Then we attach models to configured data sources to receive behaviors provided by various connectors. For example, connectors for databases implement methods for models to perform create, read, update, and delete (CRUD) operations. Furthermore, you can expose models and their methods as REST APIs so client applications can easily consume them.

Individual models are easy to understand and work with. But in reality, models are often connected or related. The moment you start to build a real-world application with multiple models, relations between models will come into the picture naturally. For example:

  • A customer has many orders and each order is owned by a customer.
  • A user can be assigned to one or more roles and a role can have zero or more users.
  • A physician takes care of many patients through appointments. A patient can see many physicians too.

With the connected models, LoopBack can present data to client applications as a connected graph, with connectors to interact with the backend systems behind the scenes. The data graph is then exposed as a set of APIs for the client to not only interact with each of the model instances, but also “slice and dice” the information based on the client’s need.

The first part of the blog walks through different types of relations, how to define them, and what Node.js APIs are available for navigating and associating the connected models. The second part of the blog describes how to map data navigation and aggregation capabilities to REST APIs.

Read more

What’s New in Node.js v0.12 – execSync: a Synchronous API for Child Processes

Although Node.js was primarily invented for writing web servers, developers have since discovered other use cases for when to (and not to!) use Node. Surprisingly, one of these use cases turns out to be an alternative for writing shell scripts. And there’s some sense to that: Node’s cross-platform support is pretty good these days, and when you’re writing both your frontend and your backend in JavaScript, wouldn’t it be great to write your build system in JavaScript too, right?

Asynchronous is bad for shell scripts

A notable library that supports this use case is Grunt, which itself is built on top of ShellJS. However, ShellJS has a tough nut to crack: Node forces it to use asynchronous I/O. While that is great for web servers that must remain responsive at all times, it doesn’t necessarily make a lot of sense for shell scripts that require all steps to be taken in sequence.

So, the ShellJS authors have found an “interesting” workaround that allows it to run a shell command and wait for it to complete. In broad strokes, this is what it comes down to:

In other words, while the shell is executing your command, ShellJS stays active and continuously polls the filesystem to see if it can find a file that indicates that the command has completed. Kind of like Donkey.

The inefficiency and ugliness of this hack motivated the Node core team to implement a real solution – Node v0.12 should finally get support for synchronously running child processes. This actually had been on the roadmap for a long time – I remember sitting down at JSConf.eu in 2011 (!) with the now-retired Node maintainer Felix Geisendoerfer, sketching out a way to implement execSync. And now, finally, after more than two years, the feature has landed on the master branch.

Congrats, ShellJS people on the great trolling!  🙂

Read more

What’s New at StrongLoop for February 2014

The past month was busy for the engineering teams here at StrongLoop! We put a lot of content out every week and appreciate that it can be tough to stay on top of it all. So, to make it easy we’ve compiled this quick recap to catch you up on what’s new.

Updates to the slc Command Line Interface

The slc command-line tool now provides an update command to update itself and all its peer dependencies. This helps to avoid troublesome peer dependency errors when updating. See “Updating to the latest version” for details.
The slc run command has been enhanced to:

  • Automatically enable StrongOps profiling if the application has been registered using slc strongops.
  • Optionally use clustering with the –cluster option, or when NODE_ENV is “production”.
  • Optionally run a Node application as a daemon (a background process) using the –detach option.
  • Optionally direct the output of a detached daemon to a file.
  • Optionally write a PID file with the master process ID, useful to send signals to a detached process from system startup scripts used by init or upstart.


New AngularJS JavaScript SDK

This SDK is a set of tools that makes it easy to connect an AngularJS front-end to a LoopBack back-end application over a REST API.  LoopBack is an open-source framework built on top of Express, optimized for mobile and web. LoopBack makes it easy to:

  • Connect to multiple data sources including Oracle, MySQL, and MongoDB
  • Write business logic in Node.js
  • Glue on top of your existing services and data
  • Connect using JavaScript, iOS & Android SDKs.

AngularJS is an open-source JavaScript client MVC framework for building single-page web applications. Here’s how to get started.

Updated memory connector for StrongOps

The built-in memory connector enables you to test your application without connecting to an actual persistent data source, such as a database. Although the memory connector is very well tested it is not suitable for production. The memory connector supports:

  • Standard query and CRUD operations so you can test models against an in-memory data source.
  • Geo-filtering when using the find() operation with an attached model. See GeoPoint API for more information on geo-filtering.


Use StrongOps to Monitor Node Apps

Ready to start monitoring event loops, manage Node clusters and chase down memory leaks? We’ve made it easy to get started with StrongOps either locally or on your favorite cloud, with a simple npm install.

Screen Shot 2014-02-03 at 3.25.40 AM

What’s next?