{"id":13517663,"url":"https://github.com/jaystack/jaydata","last_synced_at":"2025-10-22T11:44:56.516Z","repository":{"id":3164150,"uuid":"4194908","full_name":"jaystack/jaydata","owner":"jaystack","description":"Notice: this library isn't maintained anymore","archived":true,"fork":false,"pushed_at":"2022-12-02T21:40:04.000Z","size":46757,"stargazers_count":349,"open_issues_count":170,"forks_count":92,"subscribers_count":64,"default_branch":"development","last_synced_at":"2025-10-17T08:52:12.853Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://jaydata.org","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jaystack.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"MIT-LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-05-01T18:09:37.000Z","updated_at":"2025-10-03T15:51:33.000Z","dependencies_parsed_at":"2022-08-30T22:30:08.428Z","dependency_job_id":null,"html_url":"https://github.com/jaystack/jaydata","commit_stats":null,"previous_names":["jaydata/jaydata"],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/jaystack/jaydata","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaystack%2Fjaydata","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaystack%2Fjaydata/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaystack%2Fjaydata/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaystack%2Fjaydata/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jaystack","download_url":"https://codeload.github.com/jaystack/jaydata/tar.gz/refs/heads/development","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaystack%2Fjaydata/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":280301094,"owners_count":26307258,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-21T02:00:06.614Z","response_time":58,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T05:01:36.095Z","updated_at":"2025-10-22T11:44:55.720Z","avatar_url":"https://github.com/jaystack.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"## Notice: this library isn't maintained anymore\n\nJayData is a unified data access library for JavaScript to CRUD data from different sources like WebSQL/SQLite,\nIndexedDB, MongoDb, OData, HTML5 localStorage.\nThe library can be integrated with React, Angular2, Durandal, KendoUI, Knockout.js, Handlebars.js or Sencha Touch 2 and can be used on\nNode.js as well. Check out the latest [JayData examples](https://github.com/jaystack/odata-v4-client-examples) \n\nJayData not only provides JavaScript Language Query (JSLQ) syntax to access local (in-browser and mobile)\nand remote databases, but builds the queries and executes/processes the requests of the essential data\nsources and data services to make developers able to concentrate only on the business logic.\n\nMicrosoft .NET developers can utilize Entity Framework and LINQ on server-side to perform operations on\ndata from different databases. The aim of JayData library is to give a similar tool to JavaScript developers.\n\nJayData is cross-platform (runs on HTML5 desktop and mobile browsers, can be hosted in Cordova/PhoneGap environment\non iPhone, iPad, Android or Windows Phone 8+) and cross-layer as it works on client-side and server-side (Node.JS).\n\nPlease read the release notes for current status of the providers.\n\nVisit http://jaydata.org for detailed information and documentation.\n\nOfficial builds are released on CodePlex (http://jaydata.codeplex.com) can be used to develop applications, to get\nthe structured sourcecode to develop JayData itself, visit http://github.com/jaystack/jaydata\n\nFeed of Latest releases, tutorials: https://twitter.com/jaydataorg\nFeed of commits in development branch: https://twitter.com/jaydatadev\n\nJayData comes with multiple licensing: you can use it under MIT license if ship software software under MIT,\nbut it should be used under GPL if you distribute your software under GPLv2. JayData Pro is a closed-source\ncommercial product recommended for enterprise projects and commercial development efforts.\nhttp://jaystack.com/licensing\n\n## Installation\n\n```bash\n$ npm install jaydata\n```\n\n## How to build\n\n```bash\n$ git clone https://github.com/jaystack/jaydata.git\n$ cd jaydata\n$ npm install\n$ gulp\n```\n\n## Use JayData as a standalone global library\n\n```html\n\u003cscript  type=\"text/javascript\" src=\"jaydata.min.js\"\u003e\u003c/script\u003e\n```\n\nProviders are lazy loaded from the same location as the core JayData script under the ```jaydataproviders``` folder.\nIf you want to use a JayData module, include it manually in a ```\u003cscript\u003e``` tag.\n\n## Use Jaydata with System.js\n\nUsing JayData with System.js needs a little bit of a setup and you have to map all providers you want to use in your application.\n\n```javascript\nvar map = {\n    'jaydata/core': 'lib/jaydata/jaydata.min',\n    'jaydata/odata': 'lib/jaydata/jaydataproviders/oDataProvider.min'\n};\n\nvar meta = {\n    'jaydata/odata': {\n        format: 'cjs',\n        deps: ['jaydata/core']\n    }\n};\n\nvar config = {\n    map: map,\n    meta: meta\n};\n\nSystem.config(config);\n```\n\nWith this setup you can now import the ```jaydata/odata``` module in your application code. See a full example in Angular2 [here](https://github.com/jaystack/odata-v4-client-examples/tree/master/angular2-product-editor).\n\n## Use JayData with Require.js\n\nIf you want to use Require.js to import JayData into your application, you need to set the path configuration correctly:\n\n```javascript\nrequirejs.config({\n    paths: {\n        'jaydata/core': '../lib/jaydata/jaydata.min',\n        'jaydata/odata': '../lib/jaydata/jaydataproviders/oDataProvider.min',\n    }\n});\n```\n\nSee a working example using Require.js and Durandal [here](https://github.com/jaystack/odata-v4-client-examples/tree/master/durandal-product-editor).\n\n## JayData basics in 7 simple steps\n\nIn most scenarios, the 7 simple steps of JayData basics are enough to handle data of your application. For more details, visit [http://jaydata.org](http://jaydata.org).\n\n### Step 1 - Define your data model\n\nSimple model that works online and offline as well. Define your data model:\n\n```javascript\nvar Todo = $data.Entity.extend(\"Todo\", {\n    Id: { type: \"int\", key: true, computed: true },\n    Task: { type: String, required: true, maxLength: 200 },\n    DueDate: { type: Date },\n    Completed: { type: Boolean }\n});\n\nvar TodoDatabase = $data.EntityContext.extend(\"TodoDatabase\", {\n    Todos: { type: $data.EntitySet, elementType: \"Todo\" }\n});\n```\n\n### Step 2 - Initialize the data storage\n\n#### OData\n\nYou can Initialize your context to handle an OData endpoint just by passing the OData service URL as a single string parameter.\n\n```javascript\nvar todoDB = new TodoDatabase(\"http://mysite.com/my.svc\");\n```\n\n#### Local database\n\nIf you want to use a local database, pass the name of your database as a string.\nJayData automatically detects what type of local database solution is available on the client and creates a context to an IndexedDB, WebSQL, LocalStorage or InMemory database.\n\n```javascript\nvar todoDB = new TodoDatabase(\"MyTodoDatase\");\n```\n\n#### WebSQL\n\nYou can even specify, what type of database you want to use by providing a storage provider configuration object.\n\n```javascript\nvar todoDB = new TodoDatabase({ \n    provider: 'webSql', databaseName: 'MyTodoDatabase' \n});\n```\n\n### Step 3 - Create data\n\nYou can create new data by adding new entities to an entity set.\n\n#### Simple\n\nYou can add a single entity to an entity set...\n\n```javascript\ntodoDB.onReady(function(){\n    var task = todoDB.Todos.add({ Task: 'Step0: Get this list', Completed: true });\n    todoDB.saveChanges(function(){\n        alert(task.Id);\n    });\n});\n```\n\n#### Batch\n\n...or you can create multiple new entities by using the ```addMany``` function. In the handler of the ```saveChanges``` function you will get how many entities were saved.\n\n```javascript\ntodoDB.onReady(function(){\n    var tasks = todoDB.Todos.addMany([\n        { Task: 'Step1: Define your data model'},\n        { Task: 'Step2: Initialize the data storage'},\n        { Task: 'Step3: Create data' }\n    ]);\n    todoDB.saveChanges(function(count){\n        alert(\"Created \" + count + \" new task\");\n        tasks.forEach(function(todo){ alert(todo.Id); });\n    });\n});\n```\n\n### Step 4 - Read data\n\n#### All items\n\nTo retrieve all database items as an array, use the ```toArray``` function.\n\n```javascript\ntodoDB.onReady(function(){\n    todoDB.Todos.toArray(function(todos){\n        yourTemplate.render(todos);\n    });\n});\n```\n\n#### Filter #1\n\nYou can filter your data just like the native ```filter``` function of JavaScript. If you want to handle your result in a loop use the ```forEach``` function. \n\n```javascript\ntodoDB.onReady(function(){\n    todoDB.Todos\n        .filter(function(todo){\n            return todo.Completed == true || todo.Task.startsWith(\"Step2\");\n        })\n        .forEach(function(todo){\n            yourTemplate.render(todo);\n        });\n});\n```\n\nUsing ```forEach``` is equivalent to this:\n\n```javascript\ntodoDB.onReady(function(){\n    todoDB.Todos\n        .filter(function(todo){\n            return todo.Completed == true || todo.Task.startsWith(\"Step2\");\n        })\n        .toArray(function(todos){\n            todos.forEach(function(todo){\n                yourTemplate.render(todo);\n            });\n        });\n});\n```\n\n#### Filter #2\n\nYou can pass a query parameters object as the second argument of the ```filter``` function and access these query parameters on ```this``` in the query function. \n\n```javascript\ntodoDB.onReady(function(){\n    todoDB.Todos\n        .filter(function(todo){\n            return todo.Completed == true || todo.Task.startsWith(this.stepName);\n        }, {\n            stepName: 'Step2'\n        })\n        .forEach(function(todo){\n            yourTemplate.render(todo); \n        });\n});\n```\n\n#### Filter #3\n\nInstead of a JavaScript function you can use a query string in the ```filter``` function. This is specially useful, when you want to create your query dynamically.\n\n```javascript\ntodoDB.onReady(function(){\n    var stepName = 'Step2';\n    todoDB.Todos\n        .filter(\"it.Completed || it.task.startsWith('\" + stepName + \"')\")\n        .forEach(function(todo){\n            yourTemplate.render(todo); \n        });\n});\n```\n\n#### Mapping\n\nIn some scenarios you want to just retrieve some fields of your entity and map these fields as different names.\n\n```javascript\ntodoDB.onReady(function(){\n    todoDB.Todos\n        .map(function(todo){\n            return {\n                _task: todo.Task,\n                _completed: todo.Completed\n            }\n        })\n        .toArray(function(todos){\n            yourTemplate.render(todos);\n        });\n});\n```\n\n#### Paging\n\nAs you store more and more entities in your database, it's practical to retrieve only a subset of your data by using paging functions. \n\n```javascript\ntodoDB.onReady(function(){\n    todoDB.Todos\n        .skip(2)\n        .take(3)\n        .toArray(function(todo){\n            yourTemplate.render(todo);\n        });\n});\n```\n\n#### Ordering\n\nIf you want to sort your result by a selected field, use ```orderBy``` or ```orderByDescending```. As you can still use a string instead of a function in the query function, you can dynamically construct your ordering query.\n\n```javascript\ntodoDB.onReady(function(){\n    todoDB.Todos\n        .orderBy(\"it.Task\")\n        .toArray(function(todo){\n            yourTemplate.render(todo);\n        });\n});\n```\n\nIf you want more dynamic control over order direction, use the ```order``` function. If you need descending ordering on the field, use the ```-``` sign before the field name.\n\n```javascript\ntodoDB.onReady(function(){\n    todoDB.Todos\n        .order(\"-it.Task\")\n        .toArray(function(todo){\n            yourTemplate.render(todo);\n        });\n});\n```\n\n### Step 5 - Update data\n\nTo update an entity, attach it to the context and JayData will track the changes on the entity. On calling the ```saveChanges``` function, your attached and updated entities will be saved.\n\n```javascript\ntodoDB.onReady(function(){\n    todoDB.Todos.single(\"it.Id == 1\", function(todo){\n        todoDB.attach(todo);\n        todo.Completed = true;\n        todoDB.saveChanges(function(count){\n            alert(\"Updated \" + count + \" task\");\n        });\n    });\n});\n```\n\n### Step 6 - Delete data\n\n#### Simple\n\nJust like updating data, but instead of ```attach``` you will use ```remove```.\n\n```javascript\ntodoDB.onReady(function(){\n    todoDB.Todos.single(\"it.Id == 3\", function(todo){\n        todoDB.Todos.remove(todo);\n        todoDB.saveChanges(function(count){\n            alert(\"Removed \" + count + \" task\");\n        });\n    });\n});\n```\n\n#### Batch\n\nUse the ```removeAll``` function if you want to truncate all data in a single entity set.\n\n```javascript\ntodoDB.onReady(function(){\n    todoDB.Todos.removeAll(function(){\n        alert(\"Removed all tasks\");\n    });\n});\n```\n\n### Step 7 - Generate some UI with jQuery\n\n```javascript\ntodoDB.onReady(function(){\n    todoDB.Todos\n        .forEach(function(todo) {\n            $('#todos')\n                .append('\u003cli\u003e\u003cb\u003e' + todo.Task + '\u003c/b\u003e' + (todo.Completed ? ' - completed' : '') + '\u003c/li\u003e');\n        });\n});\n```\n\n## Related projects\n\n[JaySvcUtil](https://github.com/jaystack/jaysvcutil) - Code generator tool that builds JayData data model classes from $metadata service of OData endpoints. \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjaystack%2Fjaydata","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjaystack%2Fjaydata","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjaystack%2Fjaydata/lists"}