The current build of datastore.js uses Class notation. This is great because it allows for easy access to methods and using this. when working within the class. We can get all this using objects in JavaScript as well along with the other features of objects.
Current when building a new datastore class in code
const store = new datastore.dkan(id, rootURL)
store.query(params);
To extend this would require creating a new class locally, extending it and adding our new methods to search for the particular features of the app we are building.
All of the above is currently nested in our resource_functions when calling getDKANDatastore. The code I am proposing should do the same when calling the resource_functions, but the functions now call
const store = datastore.create(identifier, rootURL);
store.query(params);
The biggest change here is the loss of the new keyword and removing of some legacy code when we had datastore types of csv or dkan.
Instead of needing to create a new class and extending it, we can now do something like this in our locals:
This PR currently has all the dist/library files included. To test out the branch just update your app's package.json to use "@civicactions/data-catalog-components": "github:GetDKAN/data-catalog-components#prototypal-inheritance", instead of the npm version and you shouldn't see any difference in your build. But you can now import datastore as a named import into your app and customize as needed.
The current build of datastore.js uses Class notation. This is great because it allows for easy access to methods and using
this.
when working within the class. We can get all this using objects in JavaScript as well along with the other features of objects.Current when building a new datastore class in code
To extend this would require creating a new class locally, extending it and adding our new methods to search for the particular features of the app we are building.
All of the above is currently nested in our resource_functions when calling getDKANDatastore. The code I am proposing should do the same when calling the resource_functions, but the functions now call
The biggest change here is the loss of the new keyword and removing of some legacy code when we had datastore types of csv or dkan.
Instead of needing to create a new class and extending it, we can now do something like this in our locals:
Or if you want to change up the create function only but keep many of the other features:
This PR currently has all the dist/library files included. To test out the branch just update your app's package.json to use
"@civicactions/data-catalog-components": "github:GetDKAN/data-catalog-components#prototypal-inheritance",
instead of the npm version and you shouldn't see any difference in your build. But you can now import datastore as a named import into your app and customize as needed.